views:

169

answers:

3

I am attempting to deploy a Rails application (which works fine in development) onto a production server. I have installed and configured Apache, Passenger, and the necessary gems. After I restart apache and navigate to the server, I get the following error:

Exception PhusionPassenger::UnknownError in PhusionPassenger::Railz::ApplicationSpawner (no such file to load -- money (MissingSourceFile))

gem list money shows:

*** LOCAL GEMS ***

money (3.0.5)

An irb session on the server:

irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'money'
=> true

The gem is required in config/environment.rb:

require 'money'

What's going on here?

Edit: The gem was installed as root:

# ls -l /usr/lib/ruby/gems/1.8/gems/money-3.0.5/lib
total 8
drwx------ 2 root root 4096 Sep  2 10:26 money
-rw-r--r-- 1 root root 1284 Sep  2 10:26 money.rb

Edit 2: After having no success with that roadblock, I realized that Passenger is sort of made to go along with Ruby Enterprise Edition, so I tried installing that. Afterwards, I used Ruby Enterprise's version of gem to install all the required gems. Now when I restart apache and navigate to my server, I get:

Exception LoadError in PhusionPassenger::Railz::ApplicationSpawner (no such file to load -- logger)

I have no problem requiring logger in either the old or new versions of Ruby:

# which irb
/usr/bin/irb
# irb
irb(main):001:0> require 'logger'
=> true
irb(main):002:0> exit
# /opt/ruby-enterprise-1.8.7-2010.02/bin/irb 
irb(main):001:0> require 'logger'
=> true

Something must be going on with paths or permissions, but I followed the instructions in both the Passenger and Ruby Enterprise Edition installers exactly. Any other ideas?

+2  A: 

Apache/Passenger runs the ruby process as root (or www-data), make sure you didn't install the Gem in a local repository.

You probably need to become superuser before installing the gem.


Answer 2:

The correct way to require a Gem is not using require, but using

config.gem "money"
Simone Carletti
I edited my post. The gem was installed as root and seems to be world-readable.
jrdioko
Updated my answer.
Simone Carletti
Thanks. The money gem documentation (http://money.rubyforge.org/) says to use `require 'money'`. Replacing the require in my environment.rb with `config.gem "money"` causes Passenger to give me the error: `undefined local variable or method `config' for main:Object`. Also, I should mention everything works fine in my development environment with the same code.
jrdioko
+1  A: 

are you using the same version of ruby for both?

rogerdpack
Yes, I believe so.
jrdioko
maybe use passenger 3 and see if it has the same problem?
rogerdpack
This has to be a permissions or path problem, I'd think... I'd rather stay with the current stable version of Passenger.
jrdioko
A: 

Thanks all for your help. We investigated some more and found some of the required files (the gems themselves, I believe) were installed with the wrong permissions (not readable by the user that runs Apache/Passenger). I'm not sure why that happened, as they were installed the normal way as root (maybe some non-standard umask was the issue?), but changing permissions on those files fixed the problem.

jrdioko