# Environment.rb GEM\_PATH -- problem deploying to shared host

**URL:** <https://www.ruby-forum.com/t/environment-rb-gem-path-problem-deploying-to-shared-host/172727>\
**Category:** Rails\
**Created:** [July 27, 2009, 4:57am UTC](https://www.ruby-forum.com/t/environment-rb-gem-path-problem-deploying-to-shared-host/172727 "2009-07-27T04:57:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Danny\_Owens](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/73ab20/32.png) [@Danny\_Owens](https://www.ruby-forum.com/u/Danny_Owens)\
**Post date:** [July 27, 2009, 4:57am UTC](https://www.ruby-forum.com/t/environment-rb-gem-path-problem-deploying-to-shared-host/172727/1 "2009-07-27T04:57:06Z")

</div>

I’m a long time listener, first time caller – this is the first time  
I’ve deployed a rails app to a shared host so please bear with me.  
I’ve gotten all my GEM\_PATH variables set up in .bash\_profile, .gemrc,  
etc. and everything seems to be working. I can require all the  
necessary gems from the ruby console, but when I try to launch the  
application it fails to find the gems installed in the local user  
directory.

It seems the issue must be in environment.rb, where I’ve tried a half-  
dozen different approaches to set my GEM\_PATH but without any luck.  
After much searching around on google I still don’t feel like I have a  
good handle on exactly how environment.rb works / should be used.

I’ve been banging my head on the wall here for a while, so any and all  
help is greatly appreciated!

Here are the details:

# mongrel.log

* * *

\*\* Starting Rails with production environment…  
/usr/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:31:in  
`gem\_original\_require’: no such file to load – haml  
(MissingSourceFile)

# environment.rb

RAILS\_GEM\_VERSION = ‘2.3.3’ unless defined? RAILS\_GEM\_VERSION  
ENV[‘GEM\_PATH’] = ‘/home/\*\*\*\*\*\*/ruby/gems:/usr/local/lib/ruby/gems/  
1.8’

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

Rails::Initializer.run do |config|

config.gem “authlogic”  
config.time\_zone = ‘UTC’

end

# gem environment

* * *

RubyGems Environment:

- RUBYGEMS VERSION: 1.3.4
- RUBY VERSION: 1.8.5 (2006-08-25) [i686-linux]
- INSTALLATION DIRECTORY: /home/\*\*\*\*\*\*/ruby/gems
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /home/\*\*\*\*\*\*/ruby/gems/bin
- RUBYGEMS PLATFORMS:
  - ruby
  - x86-linux

- GEM PATHS:
  - /home/\*\*\*\*\*\*/ruby/gems
  - /usr/local/lib/ruby/gems/1.8

- GEM CONFIGURATION:
  - :update\_sources =\> true
  - :verbose =\> true
  - :benchmark =\> false
  - :backtrace =\> false
  - :bulk\_threshold =\> 1000
  - “gem” =\> “–remote --gen-rdoc --run-tests”
  - “gemhome” =\> “/home/\*\*\*\*\*\*/ruby/gems”
  - “gempath” =\> [“/home/\*\*\*\*\*\*/ruby/gems”, “/usr/local/lib/ruby/  
gems/1.8”]
  - “rdoc” =\> “–inline-source --line-numbers”

- REMOTE SOURCES:
  - [http://gems.rubyforge.org/](http://gems.rubyforge.org/)

# gem list --local

* * *

\*\*\* LOCAL GEMS \*\*\*

actionmailer (2.3.3, 2.3.2, 2.1.0, 2.0.2, 1.2.5, 1.2.1)  
actionpack (2.3.3, 2.3.2, 2.1.0, 2.0.2, 1.13.6, 1.12.5, 1.12.1)  
actionwebservice (1.2.6, 1.1.6, 1.1.2)  
activerecord (2.3.3, 2.3.2, 2.1.0, 2.0.2, 1.15.6, 1.14.4, 1.14.2)  
activeresource (2.3.3, 2.3.2, 2.1.0, 2.0.2)  
activesupport (2.3.3, 2.3.2, 2.1.0, 2.0.2, 1.4.4, 1.3.1)  
authlogic (2.1.1)  
BlueCloth (1.0.0)  
builder (2.1.2)  
camping (1.5.180)  
cgi\_multipart\_eof\_fix (2.5.0)  
daemons (1.0.10, 1.0.9)  
fastthread (1.0.7)  
fcgi (0.8.7)  
gem\_plugin (0.2.3)  
haml (2.2.2)  
htmltools (1.10)  
image\_science (1.2.0)  
markaby (0.5)  
memcache-client (1.7.4)  
metaid (1.0)  
mongrel (1.1.5)  
mysql (2.7)  
rack (1.0.0)  
rails (2.3.3, 2.3.2)  
rake (0.8.7, 0.8.1, 0.7.1)  
RedCloth (4.2.2, 3.0.4)  
rubyful\_soup (1.0.4)  
rubygems-update (1.3.4, 1.1.1)  
rubypants (0.2.0)  
sources (0.0.1)  
syntax (1.0.0)  
test-spec (0.10.0)

# irb

* * *

irb(main):001:0\> require ‘rubygems’  
=\> true  
irb(main):002:0\> require ‘haml’  
=\> true  
irb(main):003:0\>

Thanks! -Danny

---

<div class="post-metadata">

**Author:** ![Danny\_Owens](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/73ab20/32.png) [@Danny\_Owens](https://www.ruby-forum.com/u/Danny_Owens)\
**Post date:** [July 27, 2009, 10:53am UTC](https://www.ruby-forum.com/t/environment-rb-gem-path-problem-deploying-to-shared-host/172727/2 "2009-07-27T10:53:02Z")

</div>

You’ll need to set GEM\_PATH a lot earlier than environment.rb to have  
it work - that file is loaded by the Rails initializer, which (in your  
environment) appears to be coming from an installed gem. You’ll want  
to put the setting in either .bashrc (which is loaded for non-  
interactive shells on some systems) or the Mongrel config someplace.  
Settings in .bash\_profile are typically only added when running an  
actual login shell.

–Matt J.

---

<div class="post-metadata">

**Author:** ![Danny\_Owens](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/73ab20/32.png) [@Danny\_Owens](https://www.ruby-forum.com/u/Danny_Owens)\
**Post date:** [July 27, 2009, 9:06pm UTC](https://www.ruby-forum.com/t/environment-rb-gem-path-problem-deploying-to-shared-host/172727/3 "2009-07-27T21:06:27Z")

</div>

Matt J. wrote:

> You’ll need to set GEM\_PATH a lot earlier than environment.rb to have  
> it work - that file is loaded by the Rails initializer, which (in your  
> environment) appears to be coming from an installed gem. You’ll want  
> to put the setting in either .bashrc (which is loaded for non-  
> interactive shells on some systems) or the Mongrel config someplace.  
> Settings in .bash\_profile are typically only added when running an  
> actual login shell.
> 
> –Matt J.

My .bashrc doesn’t get run as the server starts. I’ve tried placing the  
GEM\_PATH and GEM\_HOME in the dispatcher, but I still see the same  
problem: gems required by my app are not being found. No search is made  
of the local path. Where would you guys suggest placing the assignment  
to ENV[‘GEM\_PATH’] (and GEM\_HOME)?

Ron

---

<div class="post-metadata">

**Author:** ![Danny\_Owens](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/73ab20/32.png) [@Danny\_Owens](https://www.ruby-forum.com/u/Danny_Owens)\
**Post date:** [July 28, 2009, 2:48am UTC](https://www.ruby-forum.com/t/environment-rb-gem-path-problem-deploying-to-shared-host/172727/4 "2009-07-28T02:48:18Z")

</div>

Thanks for the help Matt, I gave the .bashrc solution a try but  
without any luck – it must not be loading on their system. As for  
the mongrel config solution – which file? Can this be solved with a  
mongrel\_cluster.yml inside the application folder?

-Danny

---

<div class="post-metadata">

**Author:** ![Danny\_Owens](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/73ab20/32.png) [@Danny\_Owens](https://www.ruby-forum.com/u/Danny_Owens)\
**Post date:** [July 28, 2009, 5:05pm UTC](https://www.ruby-forum.com/t/environment-rb-gem-path-problem-deploying-to-shared-host/172727/5 "2009-07-28T17:05:12Z")

</div>

Nope - also too late. It would have to be set before the mongrels  
start; I’m not sure where that would be.

The other option would be to switch to the Rubygems standard location  
of ~/.gem - that will be picked up automatically.

–Matt J.
