environment.rb GEM_PATH -- problem deploying to shared host

62 views
Skip to first unread message

Danny Owens

unread,
Jul 26, 2009, 4:14:39 PM7/26/09
to Ruby on Rails: Talk
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/

# 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

Matt Jones

unread,
Jul 27, 2009, 4:52:12 AM7/27/09
to Ruby on Rails: Talk
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 Jones
>      -http://gems.rubyforge.org/

Ron Barry

unread,
Jul 27, 2009, 3:06:27 PM7/27/09
to rubyonra...@googlegroups.com
Matt Jones 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 Jones

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
--
Posted via http://www.ruby-forum.com/.

Danny Owens

unread,
Jul 27, 2009, 8:47:11 PM7/27/09
to Ruby on Rails: Talk
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

Matt Jones

unread,
Jul 28, 2009, 11:04:20 AM7/28/09
to Ruby on Rails: Talk
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 Jones
Reply all
Reply to author
Forward
0 new messages