postmodern / chruby

Changes the current Ruby
MIT License
2.86k stars 190 forks source link

bundle install keeps looking for non-existent ruby #300

Closed jrochkind closed 9 years ago

jrochkind commented 9 years ago

I can't quite understand what's going on. I installed ruby-2.0.0-p576, and could switch to it with chruby, but bundle install kept trying to use ruby-2.0.0-p247 instead.

I deleted ruby-2.0.0-p247 entirely, and for good measure deleted p576 too and re-installed it. Now p576 is the only ruby 2.0.0 I have. But when I switch to it with chruby and try bundle install -- it still keeps trying to use ruby-2.0.0-p247, which does not exist, and complaining about it. I can't figure out what would even possibly be remembering p247.

$ chruby 2.0.0-p576
$ ruby -v
ruby 2.0.0p576 (2014-09-19 revision 47628) [x86_64-darwin12.5.0]
$ bundle install
-bash: /Users/jrochkind/.gem/ruby/2.0.0/bin/bundle: /opt/rubies/ruby-2.0.0-p247/bin/ruby: bad interpreter: No such file or directory
$ ls /opt/rubies/
1.8.7-p374      rubinius-2.0.0-rc1  ruby-2.0.0-p576
jruby-1.6.8     ruby-1.9.3-p429     ruby-2.1.0
jruby-1.7.16        ruby-1.9.3-p448     ruby-2.1.3
jruby-1.7.6     ruby-1.9.3-p484

Any idea what's going on and what I do about it? Thanks!

jrochkind commented 9 years ago

Okay, I seem to have solved it by rm -rf ~/.gem/ruby/2.0.0, and then re-loading chruby, switching to 2.0.0-p576, and reinstalling all gems I need from scratch, starting with bundler itself.

I don't really understand what happened though, and if a bug in chruby was perhaps triggered?

jrafanie commented 9 years ago

@jrochkind I believe you are hitting #163, where gems are shared among ruby 2.0 patchlevels and the rubygems binstubs are looking for the prior ruby. Several solutions exist in that issue but I typically just do what you did, rm -rf the /Users/jrochkind/.gem/ruby/2.0.0/ directory and bundle to install the gems with the new 2.0 patch version. Note: this will remove all gems that are not in that app's bundle so the --pristine option might be better for you. YMMV.

postmodern commented 9 years ago

@jrochkind try running gem pristin --only-executables --env-shebang to re-generate the rubygem bin stubs.

postmodern commented 9 years ago

Closing this. Adding --env-shebang to ~/.gemrc is also a viable workaround until rubygems defaults to #!/usr/bin/env.