cicit
cicit

Reputation: 591

Ruby install broken

I have a Mac running Yosemite (10.10.2) and I have ruby 2.2.2 installed on it using brew (and I tried rbenv as well). Anytime I run bundle, rake, or anything ruby related, I get this error:

$ bundle
/usr/local/Cellar/ruby/2.2.2/lib/ruby/2.2.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'bundler' (>= 0) among 9 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/cici/.gem/ruby/2.2.0:/usr/local/lib/ruby/gems/2.2.0:/usr/local/Cellar/ruby/2.2.2/lib/ruby/gems/2.2.0', execute `gem env` for more information
from /usr/local/Cellar/ruby/2.2.2/lib/ruby/2.2.0/rubygems/dependency.rb:324:in `to_spec'
from /usr/local/Cellar/ruby/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_gem.rb:64:in `gem'
from /usr/local/bin/bundle:22:in `<main>'

I got into this situation trying to fix the openssl bug. Anyway, the error message is correct, that I don't have the bundler gem in those paths. I just don't understand why the paths I do have are there. I don't have this path:

 /Users/cici/.gem/ruby/2.2.0

instead, it is:

/Users/cici/.gem/ruby/2.0.0

I installed 2.2.2 using rbenv, so I am not sure a) why is 2.2.0 on the GEM_PATH and b) why do I have 2.0.0 under .gem? Here is the output of which:

$ which -a ruby
/usr/local/bin/ruby
/usr/local/bin/ruby
/usr/local/bin/ruby
/usr/bin/ruby
/usr/bin/ruby
/usr/local/bin//ruby

/usr/local/bin/ruby is a symbolic link to /usr/bin/ruby. I am not sure what that last entry is! The version returns:

$ ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]

How can I clean this all up and start over? I have tried rbenv uninstall as well as using brew to install and uninstall.

Thanks!

Upvotes: 2

Views: 1402

Answers (1)

Max
Max

Reputation: 22315

Ruby looks for gems in version-specific paths, ignoring the patch version. So if you previously installed gems under Ruby 2.0.x, they went in /Users/cici/.gem/ruby/2.0.0 but now that you've installed Ruby 2.2.x, it's looking in /Users/cici/.gem/ruby/2.2.0.

This can be an issue when you upgrade Ruby, because all of your gem executables (e.g. bundle) are still in your $PATH, but their required files are no longer in Ruby's load path because of the new version. Try running which bundle; I bet it's in some path like /Users/cici/.gem/ruby/2.0.0/bin.

The solution is to reinstall all of your gems, and to possibly update your $PATH to not include executables from the older version. rbenv should handle that last part if you set it up correctly.

Upvotes: 1

Related Questions