views:

30

answers:

2

This is a production server. I have Passenger installed and it works properly for the most part. However, I always have to pack the gems with the projects. If I don't, I get this error message:

Missing the Rails 2.3.8 gem. Please `gem install -v=2.3.8 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed. 

gem list --local returns rails 2.3.8 as well as 2.3.5 so the gem is actually not missing. Since I could not resolve this issue, I keep including the rails gem in every project (which results is a properly working application).

Any ideas?

P.S I did try the suggestions of the error message, my config is asking for 2.3.8 which I have installed

+2  A: 

Make sure you are installing/running the gem command with the same user permission as Passenger.

By default, Passenger runs inside Apache which has superuser privileges. If you type gem install, the Gems will be saved in your user folder unless you are root.

Simone Carletti
I installed the gems with sudo, and rails 2.3.8 gem appear when I do gem list --local as the local user as well as root.
eakkas
A: 

If you're installing gems logged in as a normal user (non-root) or without using sudo, your gems go into .gems folder in your home directory (eg. /home/matt/.gems) and Passenger cannot find them.

You can either install them as root/sudo or add your local directory to your GEM_HOME/GEM_PATH. Not sure if this is the best solution, but I put this at the top of config/environment.rb in my application:

if ENV['RAILS_ENV'] == 'production'
  ENV['HOME'] = "/home/matt"
  ENV['GEM_HOME'] = "/home/matt/.gems"
  ENV['GEM_PATH'] = "/home/matt/.gems"
end
Matt