2

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!

cicit
  • 581
  • 5
  • 24

1 Answers1

1

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.

Max
  • 21,123
  • 5
  • 49
  • 71
  • $ which bundle /usr/local/bin/bundle – cicit Apr 18 '15 at 19:15
  • That worked! However, I am back to the original error that started me down this rabbit hole. Gem::Ext::BuildError: ERROR: Failed to build gem native extension. /usr/local/opt/ruby/bin/ruby -r ./siteconf20150418-14037-1q9v0rr.rb extconf.rb checking for pg_config... no No pg_config... trying anyway. If building fails, please try again with --with-pg-config=/path/to/pg_config checking for libpq-fe.h... no Can't find the 'libpq-fe.h header *** extconf.rb failed *** – cicit Apr 18 '15 at 19:35
  • http://stackoverflow.com/questions/6040583/cant-find-the-libpq-fe-h-header-when-trying-to-install-pg-gem – Max Apr 19 '15 at 14:55
  • Right...there are alot of answers on stackoverflow for the error, but none of them seem to solve my issue. – cicit Apr 19 '15 at 19:10