What is the default search path for Ruby gems? i.e. the default GEM_HOME
20,591
Type gem env
. That will tell you what you want to know.
Related videos on Youtube
Comments
-
Max Jacobson almost 2 years
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 variableGEM_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 settingGEM_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 variableRUBYLIB
. However, where does the rubygem system search for gems? -
barlop over 4 yearsit gives three directories eg on osx
/Library/Ruby/Gems/2.3.0
. and/Users/apple/.gem/ruby/2.3.0
and/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0
. So which is default for GEM_PATH and which is default for GEM_HOME? -
David Hull about 3 yearsYou can use
gem env gemhome
andgem env gempath
. To find the user gemhome, you can useruby -e 'print Gem.user_dir'