views:

276

answers:

2

I have been trying to setup nginx with passenger for a few days now and keep running into problems. When I go to my Rails application with my browser it says: 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.

If I type gem list in my terminal it shows: rails (3.0.0, 2.3.8, 2.3.5)

What is funny is that passenger will find my ruby gems just fine when I use it with Apache on the same machine! But I would like to experiment with nginx because Apache is not doing what I want.

The machine is Ubuntu 10.04 Server

  • which ruby Shows: /usr/local/bin/ruby (REE)
  • These are the passenger directives in the nginx.conf:
    • passenger_root /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.15; passenger_ruby /usr/local/bin/ruby;
A: 

As a check, are you sure your passenger is installed in the correct version of ruby. basically

Both the rubies have separate gems meaning you have to install the other in one..

Check in the /usr/local/lib/ruby/gems/1.8/gems Directory to see if rails 2.3.8 is present. You need to install it in the this ruby.

Both rubies will have separate gem bin files for installation..

possibly /usr/bin/gem is for the system ruby and /usr/local/bin/gem is for your installation of REE

Rishav Rastogi
when I check /usr/local/lib/ruby/gems/1.8/gems it shows the rails 2.3.8 gem. When i type 'which gem' it shows /usr/local/bin/gem
Nik Petersen
hmm it may be possible that rails 3 + latest rack version may be causing the issue. Just for testing sake, remove rails 3 and latest rack version .. I ll try this on my machine and let you know. If this doesn't work.. try #passenger on the irc,
Rishav Rastogi
When I do that I get: Missing the Rails gem. Please `gem install -v= rails`
Nik Petersen
Its almost as if ruby cannot find my gems when passenger loads under nginx. No problem under apache2 though
Nik Petersen
A: 

@Nik Rishav is correct in that you have to be careful when installing Ruby Enterprise Edition (REE) along side the system Ruby. Installing REE incorrectly can cause some very strange things to happen.

While Rails 3.0 could be the cause of your issues, my gut tells me your real issue is one missed step when installing REE. But, just-in-case this doesn't work, a quick Google search will show you any number of good tutorials showing you how to host a Rails app with Phusion Passenger for Nginx. Well, let's give it a go, shall we!

REE runs fine alongside system Ruby, but you have to install it into its own directory. For example:

/opt/ruby-enterprise-X.X.X/bin/ruby

Your other option is to only install REE, but this might not be an option for you. I suspect that when Nginx runs, it does find REE as you have specified it. Did you install Passenger for Nginx from the REE stack?

/opt/ruby-enterprise-X.X.X/bin/passenger-install-apache2-module

If you haven't, you might want to look into that. I'll assume you did.

From your description, it doesn't look like you have told REE where to find your gems. To do this, you need to set REE as the default Ruby Interpreter. To do this, add an entry to the file /etc/environment. On Ubuntu, the directory is /etc/environment. Add REE's bin directory to the PATH environment variable, like this:

PATH="/opt/ruby-enterprise-x.x.x/bin:/usr/local/sbin:/usr/local/bin"

Placing REE first in the PATH will set it as the default Ruby interpreter.

Then restart Nginx, like so:

sudo /etc/init.d/nginx restart

Hopefully this helps. I've had my share of deployment issues and it truly can be frustrating. Wouldn't wish it on anyone...Good luck!

Adam Williams
Hmm, maybe I should start from scratch on a virtual machine and see if I can go though all the steps without missing them. I thought REE was installed at /usr/local/bin/ruby on my machine, and Ruby was installed at /usr/bin/ruby. I think you are right about removing ruby standard and trying REE by itself. It would reduce it to less moving parts that could cause issues.
Nik Petersen