Search code examples
rubyrubygemspassengerruby-enterprise-edition

Ruby Passenger: no such file to load bundler


I installed Phusion Passenger with Nginx, configured Nginx to point to the right directory, Then I ran webapp directory and this has downloaded the gemfiles, but it can't find the gems.

When I visit the site I get the standard Passenger error page which says:

Error message:
no such file to load -- bundler

Here's the full error: http://tinypic.com/view.php?pic=vpx36r&s=7

I've do a gem install bundler so I know bundler is installed, but I think it's looking in the wrong place for the gems.

It appears as if Passenger has installed ruby-enterprise-1.8.7 and it looks like 1.8 was already installed in this box.

gem env gives me the following:

  - RUBYGEMS VERSION: 1.4.2
  - RUBY VERSION: 1.8.7 (2009-12-24 patchlevel 248) [x86_64-linux]
  - INSTALLATION DIRECTORY: /opt/local/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /opt/local/ruby-enterprise-1.8.7-2010.01/bin/ruby
  - EXECUTABLE DIRECTORY: /opt/local/ruby-enterprise-1.8.7-2010.01/bin
  - RUBYGEMS PLATFORMS:
      - ruby
      - x86_64-linux
    - GEM PATHS:
      - /opt/local/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8
 - /root/.gem/ruby/1.8
    - GEM CONFIGURATION:
       - :update_sources => true
       - :verbose => true
       - :benchmark => false
       - :backtrace => false
       - :bulk_threshold => 1000
    - REMOTE SOURCES:
       - http://rubygems.org/

From what I've read it appears to be a path issue, but I don't know what the best course of action is to fix it.

Here's the output of

which ruby:

/opt/local/ree/bin/ruby

which bundle:

/opt/local/ree/bin/bundle

I've run bundle install in that directory and it's given me:

Your bundle is complete! It was installed into ./vendor/bundle

Solution

  • it looks like you have some path issues (as you already stated). try to check why you have two different paths for your ruby installation.

    I mean, according to your gem env output, you have some installation on

     /opt/local/ruby-enterprise-1.8.7-2010.01/
    

    but you also have ruby and bunlder under

    /opt/local/ree/
    

    so, start from here to check if all the paths are correct and/or you haven't any double installations (well, it's just enough to check if your ENVs are coherent).

    Another issue could be related to your nginx.conf, you should have something like this:

    [...]
     http {
      passenger_root /your/path/to/passenger/gem;
      passenger_ruby /path/to/ruby;
      [...]
     }
    

    UPDATE (just saw additional comments with nginx.conf):

    as you can see, there's a problem with paths: you have two paths for ruby and gems installs:

    /opt/local/ruby-enterprise....
    

    and

    /opt/local/ree
    

    you should remove the latter (not phisically, just review ENVs to point to the first one)

    EDIT: to change your env, you can append the following line to your /etc/bash.bashrc (or whaterver file is loaded from your shell by default):

    PATH="/opt/local/ruby-enterprise-1.8.7-2010.01/bin:$PATH"
    

    then logout and login, or for a quick test, launche this command from shell:

    source /etc/bash.bashrc

    now, retry to see what binary is used by default with:

    which ruby
    which gem
    which rake
    gem env
    ...
    

    everything should have the /opt/local/ruby-enterprise-1.8.7-2010.01/ prefix (that's what is used from nginx and passenger configs).

    UPDATE2: from the comments, it turned out that you have at least 3 ruby installs:

    • ruby from your package manager in /usr/lib/ruby/ (are you using ubuntu linux?)
    • a ruby in /opt/local/ree/
    • a ruby in /opt/local/ruby-enterprise-....

    at this point, the best thing to do is:

    • uninstall all the rubys under /opt/local/ and all their gems
    • uninstall (purge) system provided ruby packages (you don't need it)

    • install and setup RVM: https://rvm.io

    • re-install passenger using RVM: https://rvm.io/integration/passenger/
    • fix nginx.conf to use passenger path and ruby