Bug 222872 - lang/ruby3{1,2,3}: Fails to build with POSIX-compliant sh -c
Summary: lang/ruby3{1,2,3}: Fails to build with POSIX-compliant sh -c
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Koichiro Iwao
URL:
Keywords:
Depends on:
Blocks: 220587
  Show dependency treegraph
 
Reported: 2017-10-08 21:10 UTC by Jilles Tjoelker
Modified: 2025-03-12 02:09 UTC (History)
6 users (show)

See Also:
bugzilla: maintainer-feedback? (ruby)


Attachments
allow both current and POSIX-compliant sh -c (906 bytes, patch)
2017-10-08 21:10 UTC, Jilles Tjoelker
no flags Details | Diff
allow both current and POSIX-compliant sh -c (906 bytes, patch)
2025-03-11 03:16 UTC, Mark Linimon
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jilles Tjoelker freebsd_committer freebsd_triage 2017-10-08 21:10:45 UTC
Created attachment 187013 [details]
allow both current and POSIX-compliant sh -c

The RB_SET_CONF_VAR macro uses a construct like

sh -c 'command' -- arg0 arg1

and assume that $0 will expand to arg0 and $1 will expand to arg1.

Our current sh implements it that way. However, POSIX specifies that $0 will
expand to -- and $1 will expand to arg0, since the command string is an operand
and not an option-argument. Bug #220587 requests making sh POSIX-compliant in
this regard.

If the argument after the command string does not start with '-', the current
sh behaves as required by POSIX. Therefore, the macros should be adjusted so
this is always the case.

Tested with poudriere, stable/10 with patched head sh.
Comment 1 Jilles Tjoelker freebsd_committer freebsd_triage 2017-10-08 21:17:56 UTC
The same problem affects lang/ruby23 and lang/ruby24, and the patch is the same (though context differs a bit for lang/ruby24).
Comment 2 Walter Schwarzenfeld 2019-02-06 13:03:50 UTC
ping!
Comment 3 Koichiro Iwao freebsd_committer freebsd_triage 2019-02-08 00:38:45 UTC
ruby22 is now EoL and already removed from ports tree.
Comment 4 Koichiro Iwao freebsd_committer freebsd_triage 2019-02-08 00:43:36 UTC
Oops, it affects ruby23 and ruby24.
Comment 5 Rene Ladan freebsd_committer freebsd_triage 2021-04-06 14:48:10 UTC
Is this still relevant with lang/ruby27 ?
Comment 6 Jilles Tjoelker freebsd_committer freebsd_triage 2021-04-06 20:29:17 UTC
(In reply to Rene Ladan from comment #5)
Yes, the problematic code is still in lang/ruby26, lang/ruby27 and lang/ruby30.
Comment 7 Kubilay Kocak freebsd_committer freebsd_triage 2022-01-17 00:05:00 UTC
@Jilles Is ruby31 also affected, and should these changes go upstream?

^Triage: Patch needs updating to cover all currently affected ruby's
Comment 8 Jilles Tjoelker freebsd_committer freebsd_triage 2022-01-18 23:51:23 UTC
(In reply to Kubilay Kocak from comment #7)
The problematic code has been reformatted a bit in lang/ruby31, but is still there.

The problematic code is in the port Makefile, not in upstream code.
Comment 9 Kubilay Kocak freebsd_committer freebsd_triage 2022-01-19 01:29:22 UTC
(In reply to Jilles Tjoelker from comment #8)

Thanks, sorry I missed the location of the patch. Happy to approve a QA'd patch against all affected lang/ruby* ports if you'd like to take this to resolution
Comment 10 Rene Ladan freebsd_committer freebsd_triage 2023-04-13 20:46:59 UTC
Trim EOL lang/ruby2[67] from the title.
Comment 11 Rene Ladan freebsd_committer freebsd_triage 2024-03-31 10:41:41 UTC
Update title, lang/ruby30 expired today but the problem is still present in lang/ruby31 at least.
Comment 12 John Hein 2024-12-04 16:57:31 UTC
Why is this patch languishing in bugzilla?  There's nothing tricky here - it's trivial and correct.  Please commit the patch.  No PORTREVISION bump needed as nothing changes in the built package.

Or instead of replacing -- with RB_SET_CONF_VAR, call it "dummy" if you like that better.  But I don't suspect it's objections to the patch content that has kept this from being committed - just that it has gotten lost in time.
Comment 13 John Hein 2024-12-04 17:23:44 UTC
p.s. The same patch applies to ruby32 and ruby33
Comment 14 Mark Linimon freebsd_committer freebsd_triage 2025-03-11 03:16:38 UTC
Created attachment 258552 [details]
allow both current and POSIX-compliant sh -c

^Triage: rebase patch.
Comment 15 Koichiro Iwao freebsd_committer freebsd_triage 2025-03-11 06:08:17 UTC
Let me check.
Comment 16 Koichiro Iwao freebsd_committer freebsd_triage 2025-03-11 09:04:13 UTC
(In reply to John Hein from comment #12)
Comment 17 Koichiro Iwao freebsd_committer freebsd_triage 2025-03-11 09:15:27 UTC
(In reply to Kubilay Kocak from comment #9)
I've committed the patch to all Ruby versions and am about to push the commit to the main ports repo. All Ruby versions build fine, and there have been no changes in Ruby's behaviour. Are any other QA tests required?
Comment 18 John Hein 2025-03-11 12:08:49 UTC
(In reply to Koichiro Iwao from comment #17)
> Are any other QA tests required?

No required QA tests that I know of.

It is worthwhile to test and confirm that this change works with both older, non-compliant, /bin/sh and compliant shell implementations (and mention this in the commit message).  For what it's worth, I have tested this and confirmed this is true on older, now EOL, versions of FreeBSD (back to 4.x) through the the latest FreeBSD /bin/sh.  But feel free to independently do some testing.

Unrelated to this change, portclippy suggests different ordering of elements in the Makefile. While here, a separate commit could be made to address those (separate to keep formatting changes from distracting from the meaningful on-topic change).  But that's not at all required.
Comment 19 Koichiro Iwao freebsd_committer freebsd_triage 2025-03-11 15:12:23 UTC
(In reply to John Hein from comment #18)
Thanks, I think I can trust your test. Will push shortly.
Comment 20 commit-hook freebsd_committer freebsd_triage 2025-03-11 15:15:50 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=59deeb00ee2faaa2f74acb681cf638aae7b3cda1

commit 59deeb00ee2faaa2f74acb681cf638aae7b3cda1
Author:     Koichiro Iwao <meta@FreeBSD.org>
AuthorDate: 2025-03-11 08:42:57 +0000
Commit:     Koichiro Iwao <meta@FreeBSD.org>
CommitDate: 2025-03-11 15:15:02 +0000

    lang/ruby3{1,2,3}: Fix build with POSIX-compliant `sh -c`

    This chanes nothing in the built package, so bumping PORTREVISION is not
    required.

    PR:             222872
    Reported by:    jilles
    Tested by:      John Hein
    Approved by:    meta (myself, with ruby hat)
    Sponsored by:   Cybertrust Japan

 lang/ruby31/Makefile | 3 ++-
 lang/ruby32/Makefile | 3 ++-
 lang/ruby33/Makefile | 4 +++-
 3 files changed, 7 insertions(+), 3 deletions(-)
Comment 21 Koichiro Iwao freebsd_committer freebsd_triage 2025-03-12 02:09:54 UTC
Pushed, thanks for the patience.