RVM - Not able to use gems from the @global gemset

妖精的绣舞 提交于 2019-12-01 22:32:16

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

$ 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)

And the gem is available to the project as desired.

I ran into the same thing and did some experimenting

$ gem list

...
tzinfo (0.3.29, 0.3.28)
uglifier (1.0.0)
wirble (0.1.3)

Then in the debugger console (requires gem ruby-debug for ruby 1.8.7 or ruby-debug19 for ruby 1.9.2):

ruby-1.9.2-p180 :001 > puts `gem list`  #note that those are not quotes, but backticks

...
tzinfo (0.3.28)
wirble (0.1.3)
 => nil 

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!