mjs
mjs

Reputation: 65293

What is the default search path for Ruby gems? i.e. the default GEM_HOME

What is the default search path for Ruby gems? I'm trying to figure what directories I can pass to gem's --install-dir switch, so that I don't have to set the environment variable GEM_HOME for the gems to be found.

In particular, if I install the gem jekyll via

$ gem install --bindir /usr/local/bin --install-dir /usr/local/lib/ruby/gems/1.8 jekyll

then /usr/local/bin/jekyll can't find its libraries without explicitly setting GEM_HOME:

$ jekyll --help
/usr/lib/ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem jekyll (>= 0) (Gem::LoadError)
    from /usr/lib/ruby/1.8/rubygems.rb:214:in `activate'
    from /usr/lib/ruby/1.8/rubygems.rb:1082:in `gem'
    from /usr/local/bin/jekyll:18
$ GEM_HOME=/usr/local/lib/ruby/gems/1.8 jekyll --help
Jekyll is a blog-aware, static site generator.
[ ... ]

It seems that ruby itself will look in the directories listed in the Ruby variable $LOAD_PATH, which can be augmented by the environment variable RUBYLIB. However, where does the rubygem system search for gems?

Upvotes: 28

Views: 23064

Answers (1)

Hongli
Hongli

Reputation: 18924

Type gem env. That will tell you what you want to know.

Upvotes: 38

Related Questions