Search code examples
ruby-on-rails-3rubygemspassenger

Phusion Passenger Web application could not be started / picks wrong ruby


My RoR app fails to start, with error:

It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run:

bundle install

If that didn't work, then the problem is probably caused by your application being run under a different environment than it's supposed to. Please check the following:

Is this app supposed to be run as the railsapp user?
Is this app being run on the correct Ruby interpreter? Below you will see which Ruby interpreter Phusion Passenger attempted to use.

and

Ruby interpreter command

    /usr/bin/ruby1.8

The file config/environment.rb is owned by the railsapp user. I use rbenv, and installed ruby version 2.1.1 as the global version. I use bundler to install the gem dependencies. which is all OK.

So it seems, phusion passenger picks the wrong ruby version (At least not the one I installed as global with rbenv).

How do I make Phusion passenger compile mod_rails with the ruby version installed with rbenv?

when I ran: passenger-install-apache2-module, I noticed it picked up the system installed ruby version from ubuntu as:

* Checking for Ruby development headers...
      Found: yes
      Location: /usr/lib/ruby/1.8/i486-linux/ruby.h

but 'which ruby' as railsapp user gives this:

/home/railsapp/.rbenv/shims/ruby

My gem environment is like this:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.2
  - RUBY VERSION: 2.1.1 (2014-02-24 patchlevel 76) [i686-linux]
  - INSTALLATION DIRECTORY: /home/railsapp/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0
  - RUBY EXECUTABLE: /home/railsapp/.rbenv/versions/2.1.1/bin/ruby
  - EXECUTABLE DIRECTORY: /home/railsapp/.rbenv/versions/2.1.1/bin
  - SPEC CACHE DIRECTORY: /home/railsapp/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /home/railsapp/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0
     - /home/railsapp/.gem/ruby/2.1.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /home/railsapp/.rbenv/versions/2.1.1/bin
     - /etc/rbenv/libexec
     - /home/railsapp/.rbenv/shims
     - /etc/rbenv/bin
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin
     - /usr/games

Solution

  • Use the PassengerRuby configuration option. See the official documentation.