# Setting GEM\_PATH in environment.rb

**URL:** <https://www.ruby-forum.com/t/setting-gem-path-in-environment-rb/87212>\
**Category:** Rails\
**Created:** [February 28, 2007, 10:22pm UTC](https://www.ruby-forum.com/t/setting-gem-path-in-environment-rb/87212 "2007-02-28T22:22:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hatless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/848f3c/32.png) [@hatless](https://www.ruby-forum.com/u/hatless)\
**Post date:** [February 28, 2007, 10:22pm UTC](https://www.ruby-forum.com/t/setting-gem-path-in-environment-rb/87212/1 "2007-02-28T22:22:32Z")

</div>

This isn’t a hosting-related question. I’m not looking for a way to set  
the GEM\_PATH in a shell script.

Instead, I’m trying to load gems from both the systemwide gem path and  
from a directory of app-specific gems I’ve placed in  
RAILS\_ROOT/lib/gems.

I have installed my app-specific gems from my app’s root with

gem install --install-dir lib/gems gemname

Now in lib/gems I have the usual set of subdirs – cache, bin, gems, doc  
and specifications. So far, so good.

In environment.rb immediately after the line that reads as follows:

require File.join(File.dirname( **FILE** ), ‘boot’)

I have added the following:

#Yes, this is where my default gems reside. They all work.  
ENV[‘GEM\_HOME’] = “#{RAILS\_ROOT}/…/…/ext/ruby/lib/ruby/gems/1.8”

#However, the gems in the second part of this GEM\_PATH don’t load.  
ENV[‘GEM\_PATH’] =  
“#{RAILS\_ROOT}/…/…/ext/ruby/lib/ruby/gems/1.8:#{RAILS\_ROOT}/lib/gems”

How do I get those additional gems to load? If I put rcov in my main gem  
repo, it will load when I invoke “require ‘rcov’”. If I install it to  
the secondary path, it will not.

Thanks.
