postmodern / ruby-install

Installs Ruby, JRuby, TruffleRuby, or mruby
MIT License
1.91k stars 252 forks source link

Preview and RC versions use shared sets of gems #327

Open schneems opened 5 years ago

schneems commented 5 years ago

I had preview3 installed and then I installed rc1 via ruby-install. Once I did I got these errors:

$ chruby 2.6.0
⛄ 2.6.0 🚀  /tmp
$ ruby -v
ruby 2.6.0rc1 (2018-12-06 trunk 66253) [x86_64-darwin17]
⛄ 2.6.0 🚀  /tmp
$ which bundle
/Users/rschneeman/.gem/ruby/2.6.0/bin/bundle
⛄ 2.6.0 🚀  /tmp
$ bundle -v
Traceback (most recent call last):
    2: from /Users/rschneeman/.gem/ruby/2.6.0/bin/bundle:23:in `<main>'
    1: from /Users/rschneeman/.rubies/ruby-2.6.0-preview3/lib/ruby/2.6.0/rubygems.rb:307:in `activate_bin_path'
/Users/rschneeman/.rubies/ruby-2.6.0-preview3/lib/ruby/2.6.0/rubygems.rb:288:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
⛄ 2.6.0 🚀  /tmp
$ bundle --help
Traceback (most recent call last):
    2: from /Users/rschneeman/.gem/ruby/2.6.0/bin/bundle:23:in `<main>'
    1: from /Users/rschneeman/.rubies/ruby-2.6.0-preview3/lib/ruby/2.6.0/rubygems.rb:307:in `activate_bin_path'
/Users/rschneeman/.rubies/ruby-2.6.0-preview3/lib/ruby/2.6.0/rubygems.rb:288:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)

Notice that it's trying to use /Users/rschneeman/.rubies/ruby-2.6.0-preview3. It turns out that's because even though I deleted /Users/rschneeman/.rubies/ruby-2.6.0-preview3 the gems are still installed at /Users/rschneeman/.rubies/ruby-2.6.0. There was a hardcoded shebang line in that directory which was causing the issue.

havenwood commented 5 years ago

There's a RubyGems issue ticket open for using --env-shebang if File.dirname(Gem.ruby) is in $PATH. Here's a chruby issue that discusses a proposal for intentionally sharing gems between Rubies of the same ABI, which is a related issue.

I'd personally suggest setting --env-shebang in gemrc until RubyGems adopts it as a default. (JRuby does already default to --env-shebang.)