[Rubygems-developers] Best practices for managing GEM_PATH, GEM_HOME, and related stuff?

Chad Woolley thewoolleyman at gmail.com
Tue Feb 26 13:27:03 EST 2008


I've been digging into the code in rubygems.rb and defaults.rb, and
trying to understand how to manage GEM_PATH and/or GEM_HOME -
specifically when invoking RubyGems programatically.  I know some
other people who are interested in this, so I'm going to throw out a
few scenarios as discussion points.

Scenario 1: Existing rubygems install, with some gems installed in the
default system location.  I want to programatically (such as
Gem::GemRunner) install some additional gems in a user-writeable
location (~/gems).  After additional gems are installed, they should
all (system and user-writable) be loadable with the 'gem' method
and/or require.

Scenario 2: Same as above, but on mac OS X Leopard, with all gems
under default locations /System/Library/... and /Library/... still
loadable

That's it for now.  What I'm looking for is a specific set of steps to
accomplish the above scenarios.  I don't need details on how to
programatically install gems, I know that, but managing the env vars,
default dir, and path is where I'm confused. I have some hacks to do
this, but it involves manually setting up GEM_HOME and GEM_PATH before
rubygems is ever required.  This is hard in some environments - such
as irb on Leopard, where rubygems is already required, and
ENV['GEM_PATH'] is frozen.  Maybe hard on others, such as ruby 1.9
with bundled rubygems?  I haven't played with this under 1.9...

Thanks,
-- Chad


More information about the Rubygems-developers mailing list