问题描述
我开始使用rbenv进行ruby版本管理,并且发现irb没有加载正确的ruby版本和gem版本。以下是详细信息。
irb Gem.path说:
`>> 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]`
现在在irb中输入: 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 /版本/ 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`
在shell中输入: gem env
`RubyGems Environment:
- RUBYGEMS VERSION:1.8.10
- RUBY VERSION:1.9.2(2011-07-09 patchlevel 290)[x86_64-darwin11.0.1]
- 安装DIRE CTORY:/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平台:
- ruby
- x86_64-达尔文-11
- 创业板路径:
- /Users/Air/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1
- / Users / Air /.gem/ruby/1.9.1
- 创业板配置:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- 远程来源:
- http:// rubygems.org /`
我可以看到 irb 加载了错误的 Ruby版本并加载了错误的Gem路径。有人可以帮助理解我该如何解决这个问题。我正在使用 rbenv进行ruby版本管理,不知道这是怎么回事。建议?
确保您正确设置路径并在您使用的shell中初始化rbenv。 b
$ b
我在.bash_profile中添加了以下几行:
export PATH = $ HOME / .rbenv / bin:$ PATH
eval$(rbenv init - )
还记得设置您的全球rbenv版本的ruby
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?
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
这篇关于irb加载错误的红宝石和宝石路径,使用rbenv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!