From e5a1e855a185d0b31c778519bfec461652758df0 Mon Sep 17 00:00:00 2001 From: Chris Hasinski Date: Fri, 2 Oct 2026 17:32:51 +0200 Subject: [PATCH 1/2] ir.sh: put RubyGems' bindir on RUBYPATH, so `ir -S ` finds its binstub RubyGems writes a gem's binstubs to Gem.bindir, which for IronRuby is the directory ir itself is in (RbConfig's bindir, Src/Console/bin//). ir.sh only put Src/StdLib/bin - the executables the bundled library ships - on RUBYPATH, so `./ir.sh -S doom` after `./igem.sh install doom` never saw the binstub RubyGems had just written for it. It took the first `doom` on PATH instead; on a machine with a version manager that is a native shim, which ir then tried to run as a Ruby script ("invalid multibyte character 0xCF (SyntaxError)"). The directory of ir comes after Src/StdLib/bin and before PATH, so a binstub installed for IronRuby wins over a host Ruby's command of the same name - the rule the irb entry already follows - and an existing RUBYPATH still wins for anything not here. --- ir.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ir.sh b/ir.sh index 670bc711..7477c3e1 100755 --- a/ir.sh +++ b/ir.sh @@ -59,9 +59,13 @@ fi # -S searches RUBYPATH before PATH; Src/StdLib/bin holds the executables the # bundled library ships (irb), so `./ir.sh -S irb` runs IronRuby's own rather -# than whatever binstub happens to be on PATH. An existing RUBYPATH still wins -# for anything not shipped here. -RUBYPATH="$S/bin${RUBYPATH:+:$RUBYPATH}" +# than whatever binstub happens to be on PATH. The directory ir itself is in +# is RubyGems' bindir here (RbConfig's bindir), where `igem install` writes the +# binstubs of installed gems; it comes next, so `./ir.sh -S ` +# finds the binstub written for IronRuby before a host Ruby's version of the +# same command - or a version manager's shim, which is a native executable and +# not a script at all. An existing RUBYPATH still wins for anything not here. +RUBYPATH="$S/bin:$(dirname "$IR_BIN")${RUBYPATH:+:$RUBYPATH}" export RUBYPATH exec "$IR_BIN" -X:UsePrism \ From 15e9eb020ef74d82147646a45cc048b2a8b866bb Mon Sep 17 00:00:00 2001 From: Largo Date: Tue, 13 Oct 2026 23:49:15 +0200 Subject: [PATCH 2/2] ir.sh: say plainly where an existing RUBYPATH comes in the -S search "An existing RUBYPATH still wins for anything not here" read as if the caller's RUBYPATH came first. It comes after Src/StdLib/bin and RubyGems' bindir - IronRuby's own commands first, the order Src/StdLib/bin has always had and ir.cmd uses - and ahead of PATH. --- ir.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ir.sh b/ir.sh index 7477c3e1..83f204ad 100755 --- a/ir.sh +++ b/ir.sh @@ -64,7 +64,9 @@ fi # binstubs of installed gems; it comes next, so `./ir.sh -S ` # finds the binstub written for IronRuby before a host Ruby's version of the # same command - or a version manager's shim, which is a native executable and -# not a script at all. An existing RUBYPATH still wins for anything not here. +# not a script at all. An existing RUBYPATH is searched after both - IronRuby's +# own commands come first, as they always have for Src/StdLib/bin - and still +# beats PATH for anything not found here. ir.cmd uses the same order. RUBYPATH="$S/bin:$(dirname "$IR_BIN")${RUBYPATH:+:$RUBYPATH}" export RUBYPATH