How do RVM rubies find gems?

我的未来我决定 提交于 2019-12-25 08:29:58

问题


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.



来源:https://stackoverflow.com/questions/22257965/how-do-rvm-rubies-find-gems

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