Irb loads the wrong ruby ​​and gem path using rbenv

I started using rbenv to control ruby ​​versions, and I found that irb is 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 see that irb is loading the wrong version of Ruby and loading the wrong Gem path . Can someone help to figure out how I can fix this. I use rbenv to control ruby ​​versions, not sure how this plays into things. Advice?

+2
source share
2 answers

Make sure you set your path correctly and initialize rbenv in your shell.

I added the following lines to my .bash_profile:

 export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)" 

I had problems that you show until I remember this.

Also do not forget to install the global version of rubyv ruby

+10
source

After installing ruby ​​using rbenv.

Have you restored the executable files with the command

$ rbenv rehash

+5
source

Source: https://habr.com/ru/post/1383267/


All Articles