Skip to content

Instantly share code, notes, and snippets.

@thinkerbot
Created November 8, 2010 18:28
Show Gist options
  • Save thinkerbot/668037 to your computer and use it in GitHub Desktop.
Save thinkerbot/668037 to your computer and use it in GitHub Desktop.
Illustrates GEM_HOME vs GEM_PATH
# Two ENV variables control the 'gem' command:
#
# GEM_HOME: the single path to a gem dir where gems are installed
# GEM_PATH: a standard PATH to gem dirs where gems are found
#
# A gem directory is a directory that holds gems. The 'gem' command will lay
# out and utilize the following structure:
#
# bin # installed bin scripts
# cache # .gem files ex: cache/gem_name.gem
# doc # rdoc/ri ex: doc/gem_name/rdoc
# gems # gem file ex: gems/gem_name/lib/gem_name.rb
# specifications # gemspecs ex: specifications/gem_name.gemspec
#
# As an example of usage:
export GEM_HOME=a
export GEM_PATH=a
gem install rack
gem list # shows rack
export GEM_HOME=b
export GEM_PATH=b
gem install rake
gem list # shows rake (not rack)
export GEM_PATH=a:b
gem list # shows rake and rack
# And if you set GEM_HOME=a:b, you will install into the 'a:b' directory :)
@codeitagile
Copy link

Very clear.

@pgouv
Copy link

pgouv commented Oct 29, 2016

It seems that GEM_HOME works as GEM_PATH too for searching gems.

@apoorv50
Copy link

Experiment:

export GEM_HOME = a
export GEM_PATH = b

gem list     #shows rack and rake.

Observation:
It still lists both the gems.

Conclusion:
Seems like it GEM_PATH always has GEM_HOME in it. Wonder what are the default/initial values of GEM_PATH?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment