System update breaks JRuby gem shebang on Darwin
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 4k
- Forks
- 1.9k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 81
Description
When updating RubyGems it installs a gem binscript. However the shebang for this script attempts to reference the jruby executable directly:
diff --git a/bin/gem b/bin/gem
index 37772c863f..fc75806dcc 100755
--- a/bin/gem
+++ b/bin/gem
@@ -1,4 +1,18 @@
-#!/usr/bin/env jruby
+#!/Users/headius/projects/jruby-9.2/bin/jruby
However, by default this executable is a bash script, and on Darwin (and I think on other BSDs as well) you cannot put a bash script in the shebang of another language's script. When you do, it attempts to run the language script with bash, producing errors like this:
$ gem list bundler
/Users/headius/projects/jruby-9.2/bin/gem: line 8: require: command not found
/Users/headius/projects/jruby-9.2/bin/gem: line 9: require: command not found
/Users/headius/projects/jruby-9.2/bin/gem: line 10: require: command not found
/Users/headius/projects/jruby-9.2/bin/gem: line 12: args: command not found
/Users/headius/projects/jruby-9.2/bin/gem: line 14: begin: command not found
/Users/headius/projects/jruby-9.2/bin/gem: line 15: Gem::GemRunner.new.run: command not found
/Users/headius/projects/jruby-9.2/bin/gem: line 16: rescue: command not found
/Users/headius/projects/jruby-9.2/bin/gem: line 17: exit: e.exit_code: numeric argument required
Perhaps the installation of the gem binscript should check if the executable is a script and use env instead? I am not sure what the best solution is.
Note: JRuby also has a gem jruby-launcher that when installed replaces the jruby bash script with a native binary. This executable can be put in the shebang line.
I will abide by the code of conduct.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generated bin/gem binscript and reproduce the failure on Darwin using the reported gem list bundler command with JRuby. Compare behavior when jruby is the default bash script versus the native jruby-launcher; done means the installed gem binscript no longer runs Ruby code under bash.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100