Rails/Passenger: no such file to load -- money (MissingSourceFile)

3.2k views Asked by At

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?

3

There are 3 answers

0
jrdioko On BEST ANSWER

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.

2
Simone Carletti On

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"
2
rogerdpack On

are you using the same version of ruby for both?