Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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 :)
@nicolasgarnil

This comment has been minimized.

Copy link

@nicolasgarnil nicolasgarnil commented Nov 16, 2013

Great.

@codeitagile

This comment has been minimized.

Copy link

@codeitagile codeitagile commented Aug 8, 2014

Very clear.

@parhs

This comment has been minimized.

Copy link

@parhs parhs commented Oct 29, 2016

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

@apoorv50

This comment has been minimized.

Copy link

@apoorv50 apoorv50 commented May 11, 2020

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