Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gem executables can't be executed by /bin/sh or /bin/bash on macOS #11

Open
rzane opened this issue Dec 30, 2024 · 1 comment
Open

gem executables can't be executed by /bin/sh or /bin/bash on macOS #11

rzane opened this issue Dec 30, 2024 · 1 comment

Comments

@rzane
Copy link

rzane commented Dec 30, 2024

Environment

OS: macOS 14.7.2
ARCH: arm64
SHELL: /bin/zsh

Reproduction

I'm installing Traveling Ruby like this:

$ curl -L https://github.com/YOU54F/traveling-ruby/releases/download/rel-20241122/traveling-ruby-20241122-3.2.6-osx-arm64-full.tar.gz | tar xzf -

I can install and execute a command line utility:

$ bin/gem install rspec
$ bin/rspec --version
RSpec 3.13
  - rspec-core 3.13.2
  - rspec-expectations 3.13.3
  - rspec-mocks 3.13.2
  - rspec-support 3.13.2

But, the gem executable can't be executed by /bin/sh or /bin/bash (or, at least I think that's the issue):

$ /bin/sh -c 'bin/rspec --version'
bin/rspec: line 9: require: command not found
bin/rspec: line 11: Gem.use_gemdeps: command not found
bin/rspec: line 13: version: command not found
bin/rspec: line 15: str: command not found
bin/rspec: line 17: syntax error near unexpected token `('
bin/rspec: line 17: `  str = str.b[/\A_(.*)_\z/, 1]'

$ /bin/bash -c 'bin/rspec --version' 
(same thing)

$ bin/ruby -e 'system "bin/rspec --version"'
(same thing)

It does work if I specify the interpreter explicitly:

$ sh -c 'bin/ruby bin/rspec --version'
RSpec 3.13
  - rspec-core 3.13.2
  - rspec-expectations 3.13.3
  - rspec-mocks 3.13.2
  - rspec-support 3.13.2
@rzane
Copy link
Author

rzane commented Dec 30, 2024

I did a little more digging here. Turns out, a script cannot be used as an interpreter in a shebang line on macOS.

Here's an explanation and possible solution for this issue: NixOS/nixpkgs#93757

@rzane rzane changed the title gem executables don't appear to be compatible with /bin/sh gem executables can't be executed by /bin/sh or /bin/bash on macOS Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant