[Rubygems-developers] Best practices for managing GEM_PATH, GEM_HOME, and related stuff?
drbrain at segment7.net
Tue Feb 26 20:07:33 EST 2008
On Feb 26, 2008, at 10:27 AM, Chad Woolley wrote:
> 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.
According to the documentation of your shell,
set GEM_PATH to `gem env gempath` with ~/gems added
set GEM_HOME to ~/gems
At this point, `gem install` will install gems into ~/gems.
> Scenario 2: Same as above, but on mac OS X Leopard, with all gems
> under default locations /System/Library/... and /Library/... still
> 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 should add a page to `gem help` for this.
I'm switching `gem env gempath` to be usable by shell scripts for the
next release, so you won't have to manually join them with ':'.
> 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...
Gem.clear_paths will force RubyGems to re-read GEM_HOME and GEM_PATH.
More information about the Rubygems-developers