Passenger can’t find Rails


If you are running in to an issue where you are trying to get a Rails app up and running, but are receiving the error “Missing the Rails 2.x.x gem…” when you attempt to access it despite Rails being installed and available to your system, do not panic.  Rails is just giving you an extremely unhelpful error message.

Rails catches *any* problem loading the Rails gem, and then responds with that error.

 rescue Gem::LoadError => load_error
      $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} 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.)
      exit 1

If you inspect load_error from the line above, you should see the actual error message. In my case it was that ActiveSupport required Rack v1.0.0, but Passenger had already instantiated Rack v1.1.0. This led to a failure when loading the Rails gem, which was of course incorrectly reported. My quick solution was to uninstall the new version of rack, and force the install of the older version.

As a side note: I have the world’s worst code highlighter.

, ,

  1. #1 by Throlkim on February 10th, 2010

    Phew, thanks for that – had exactly the same problem. That saved me a headache. :)

  2. #2 by Soup on May 9th, 2010

    This is very good information.

  3. #3 by Mattias Arro on May 21st, 2010

    Thanks man, you saved my day!

  4. #4 by MiddleEarther on July 24th, 2010

    I spent a good part of a day reading google posts before I gave up on this… came back to it and your post fixed it. I went and added a line to the boot.rb prior to the complaint about failing to load the gem:

    $stderr.puts “Actual load error: ” + load_error

    I really don’t see why rails would ever purposefully obscure the real error – sounds like a mistake.

(will not be published)

  1. No trackbacks yet.