Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 829
mjs Avatar asked Feb 20 '11 09:02

mjs


People also ask

Where can I find RubyGems?

The main place where libraries are hosted is RubyGems.org, a public repository of gems that can be searched and installed onto your machine. You may browse and search for gems using the RubyGems website, or use the gem command. Using gem search -r , you can search RubyGems' repository.

Where is the gem file located?

The Gemfile is wherever you want it to be - usually in the main directory of your project and the name of the file is Gemfile . It's convenient to have one because it allows you to use Bundler to manage which gems and which versions of each your project needs to run.

What are gem files in Ruby?

A Gemfile is a file that is created to describe the gem dependencies required to run a Ruby program. A Gemfile should always be placed in the root of the project directory.

Where are RubyGems installed Mac?

By default, binaries installed by gem will be placed into: /usr/local/lib/ruby/gems/3.1.


1 Answers

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

like image 185
Hongli Avatar answered Oct 15 '22 07:10

Hongli