Reputation: 1043
I started using rbenv for ruby version management and I'm finding that irb not loading the correct ruby version and gem version. Here are the details.
irb Gem.path says:
`>> Gem.path
=> ["/Users/Air/.gem/ruby/1.8", "/Library/Ruby/Gems/1.8", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8"]`
Now in irb if I type: puts $:
`>> puts $:
/Library/Ruby/Site/1.8
/Library/Ruby/Site/1.8/powerpc-darwin11.0
/Library/Ruby/Site/1.8/universal-darwin11.0
/Library/Ruby/Site
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/vendor_ruby/1.8 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/vendor_ruby/1.8/universal-darwin11.0
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/vendor_ruby
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/powerpc-darwin11.0
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0`
In the shell I type: gem env
`RubyGems Environment:
- RUBYGEMS VERSION: 1.8.10
- RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-darwin11.0.1]
- INSTALLATION DIRECTORY: /Users/Air/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /Users/Air/.rbenv/versions/1.9.2-p290/bin/ruby
- EXECUTABLE DIRECTORY: /Users/Air/.rbenv/versions/1.9.2-p290/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-11
- GEM PATHS:
- /Users/Air/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1
- /Users/Air/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/`
I can see that irb is loading the wrong Ruby version and loading the wrong Gem path. Can someone help understand how do I fix this. I am using rbenv for ruby version management not sure how that plays into things. Advice?
Upvotes: 3
Views: 7651
Reputation: 4886
Once installed ruby using rbenv.
Have you rebuilded the shim binaries using the command
$ rbenv rehash
Upvotes: 7
Reputation: 101
Make sure you are setting your path correctly and initializing rbenv in the shell you are using.
I've added the following lines to my .bash_profile:
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
I had the problems you are exhibiting until I remembered to do this.
Also remember to set your global rbenv version of ruby
Upvotes: 10