我在RVM上遇到问题。通常,我使用项目特定的宝石集;但是,最近,当我在@global gemset中安装gem时,当我在特定项目中工作时,它不可用。这是我尝试安装hpricot gem的示例。这是在安装gem并启动新外壳之后的。

$ 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 ([email protected]) [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"


有什么想法为什么在项目gemset中无法使用hpricot?捆绑器也确实存在相同的问题,但最终还是将其再次安装在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)


宝石可根据需要用于项目。

10-07 16:20