RVM - 无法使用 @global gemset 中的 gem
我的 RVM 遇到问题。一般来说,我使用项目特定的宝石集;但是,最近当我将 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 ([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"
有什么想法为什么 hpricot 在项目 gemset 中不可用吗?我在 bundler 上也遇到了同样的问题,但最终还是在 gemset 中再次安装了它。
谢谢..
I'm having an issue with RVM. In general I use project specific gemsets; however, recently when I install a gem into the @global gemset, it is not available when I'm working in a particular project. Here is an example where I was trying to install the hpricot gem. This is right after installing the gem and starting a fresh 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 ([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"
Any ideas why hpricot would not be available inside of the project gemset? I did have the same issue with bundler as well, but ended up installing it again in the gemset.
Thanks..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里的问题是我第一次安装 hpricot gem 时没有使用 @global gemset。
解释器的默认 gemset 和该解释器的 @global gemset 之间存在差异。
因此,您可以通过以下方式实现所需的结果
,并且 gem 可根据需要提供给项目。
The problem here is that I wasn't using the @global gemset when installing hpricot gem the first time.
There is a difference between the interpreter's default gemset and the @global gemset for that interpreter.
So you can achieve the desired result by
And the gem is available to the project as desired.
我遇到了同样的事情,并做了一些实验
然后在调试器控制台中(需要 gem
ruby-debug
for ruby 1.8.7 或ruby-debug19
for ruby 1.9.2) :gem list
中列出的所有内容都是来自 gemfile 或其依赖项之一的 gem。我相信 Rails 在启动应用程序之前会调用 Bundler 创建 gem 上下文。我需要更多的阅读才能确定这一点,但事实似乎就是如此。因此,根据您的情况,将
gem 'hpricot'
添加到您的 gemfile 中,您应该能够在项目上下文中使用它。I ran into the same thing and did some experimenting
Then in the debugger console (requires gem
ruby-debug
for ruby 1.8.7 orruby-debug19
for ruby 1.9.2):Everything listed in
gem list
was a gem from the gemfile or one of its dependencies. I believe Rails calls Bundler to create the gem context before launching the application. I need to be more reading to be sure of this, but this is what appears to be the case.So for your situation, add
gem 'hpricot'
to your gemfile and you should be able to use it in the context of the project.