我的 RVM 遇到问题。一般来说,我使用项目特定的 gem 集;但是,最近当我将 gem 安装到 @global gemset 中时,当我在特定项目中工作时它不可用。这是我尝试安装 hpricot gem 的示例。这是安装 gem 并启动新 shell 后的情况。
$ rvm use ruby-1.9.2
Using /home/bshaver/.rvm/gems/ruby-1.9.2-p180
$ gem list
*** LOCAL GEMS ***
bundler (1.0.12)
hpricot (0.8.4)
rake (0.8.7)
$ rvm use ruby-1.9.2@myproject-gems
Using /home/bshaver/.rvm/gems/ruby-1.9.2-p180 with gemset myproject-gems
$ gem list | grep hpricot
$ rvm info
ruby-1.9.2-p180@myproject-gems:
system:
uname: "Linux hawkeye.localdomain 2.6.35.12-88.fc14.x86_64 #1 SMP Thu Mar 31 21:21:57 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux"
bash: "/bin/bash => GNU bash, version 4.1.7(1)-release (x86_64-redhat-linux-gnu)"
zsh: " => not installed"
rvm:
version: "rvm 1.5.2 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]"
ruby:
interpreter: "ruby"
version: "1.9.2p180"
date: "2011-02-18"
platform: "x86_64-linux"
patchlevel: "2011-02-18 revision 30909"
full_version: "ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]"
homes:
gem: "/home/bshaver/.rvm/gems/ruby-1.9.2-p180@myproject-gems"
ruby: "/home/bshaver/.rvm/rubies/ruby-1.9.2-p180"
binaries:
ruby: "/home/bshaver/.rvm/rubies/ruby-1.9.2-p180/bin/ruby"
irb: "/home/bshaver/.rvm/rubies/ruby-1.9.2-p180/bin/irb"
gem: "/home/bshaver/.rvm/rubies/ruby-1.9.2-p180/bin/gem"
rake: "/home/bshaver/.rvm/gems/ruby-1.9.2-p180@global/bin/rake"
environment:
PATH: "/home/bshaver/.rvm/gems/ruby-1.9.2-p180@myproject-gems/bin:/home/bshaver/.rvm/gems/ruby-1.9.2-p180@global/bin:/home/bshaver/.rvm/rubies/ruby-1.9.2-p180/bin:/home/bshaver/.rvm/bin:/usr/local/java/bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/real/RealPlayer/:/home/bshaver/bin:/home/bshaver/test-root/bin:/home/bshaver/Documents/scripts/"
GEM_HOME: "/home/bshaver/.rvm/gems/ruby-1.9.2-p180@myproject-gems"
GEM_PATH: "/home/bshaver/.rvm/gems/ruby-1.9.2-p180@myproject-gems:/home/bshaver/.rvm/gems/ruby-1.9.2-p180@global"
MY_RUBY_HOME: "/home/bshaver/.rvm/rubies/ruby-1.9.2-p180"
IRBRC: "/home/bshaver/.rvm/rubies/ruby-1.9.2-p180/.irbrc"
RUBYOPT: ""
gemset: "myproject-gems"
有什么想法为什么 hpricot 在项目 gemset 中不可用吗?我在 bundler 上也遇到了同样的问题,但最终还是在 gemset 中再次安装了它。
谢谢..
最佳答案
这里的问题是我第一次安装 hpricot gem 时没有使用 @global gemset。
解释器的默认 gemset 和该解释器的 @global gemset 之间存在差异。
这样你就可以达到想要的结果
$ rvm use ruby-1.9.2@global
Using /home/bshaver/.rvm/gems/ruby-1.9.2-p180 with gemset global
$ gem install validation_refelection
Fetching: validation_reflection-1.0.0.gem (100%)
Successfully installed validation_reflection-1.0.0
1 gem installed
Installing ri documentation for validation_reflection-1.0.0...
Installing RDoc documentation for validation_reflection-1.0.0...
$ rvm use ruby-1.9.2@myproject-gems
Using /home/bshaver/.rvm/gems/ruby-1.9.2-p180 with gemset myproject-gems
$ gem list | grep validation_reflection
validation_reflection (1.0.0)
并且该 gem 可根据需要提供给项目。
关于rubygems - RVM - 无法使用 @global gemset 中的 gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5952565/