How do RVM rubies find gems?

2019-08-30 13:57发布

问题:

I'm using Ruby 1.8.6 under RVM on Mac OS X (10.9.2). I installed everything as a local user (not root), and then installed a gem using:

gem install gli -v 1.6

When I run a ruby with require('gli'), I get the error:

in `require': no such file to load -- gli (LoadError)

even though gem list shows gli (1.6.0).

I don't know exactly how RVM does its gemsets, but there is no gli.rb file in any of the directories in the $LOAD_PATH.

How does RVM interact with the $LOAD_PATH to find the necessary gems in the gemset?

回答1:

Try adding a require 'rubygems' at the top of your source file. In 1.8 rubygems aren't required by default.

Thus said, regarding gem paths:

GEM_HOME indicates where gems are installed. To find out what it is for your case do:

$ echo $GEM_HOME

This should display an RVM-related path, since RVM changes this environment variable in order to make the $ gem install command install gems in its directories.