3

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 (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"

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..

shakerlxxv
  • 412
  • 4
  • 8

2 Answers2

2

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.

shakerlxxv
  • 412
  • 4
  • 8
0

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.

Eric Hu
  • 18,048
  • 9
  • 51
  • 67
  • Thanks Eric for the response. If I understand correctly what your saying, its not working for me. When I add 'hpricot' to the Gemfile, then it should pass the `bundle check`, but it comes back with **Your Gemfile's dependencies could not be satisfied** even though the missing gem is installed _somewhere_ in the GEM_PATH. – shakerlxxv Jul 12 '11 at 21:58
  • You still have to run `bundle install` after adding this to your gemfile. I believe bundler creates a separate context for each project and will only check those folders. Gems that are installed with `gem install ` aren't available until you put them in the gemfile and run `bundle install`. – Eric Hu Jul 12 '11 at 22:15
  • Ah, but running `bundle install` installs a 2nd instance of the missing gems into the project specific gemset. According to the RVM reference, the [@global](https://rvm.beginrescueend.com/gemsets/global/) should allow the single copy of the gem to be shared between projects. However, while I was looking to find the 2 directories where my gem was getting installed, the answer presented itself, as the first installation directory was not under the **@global** gemset. – shakerlxxv Jul 13 '11 at 01:48