Ruby Passenger: no such file to load bundler
Asked Answered
A

1

6

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
Archipelago answered 18/6, 2011 at 9:21 Comment(8)
what error do you receive? and when?Clarkclarke
"Error message: no such file to load -- bundler" I've also updated the questionArchipelago
ok, check these: 1) where you installed ruby (run: which ruby) and gem (which gem); 2) check for bundler (which bundler); 3) cd into app and run "bundle install"Clarkclarke
I've added those details to the question.Archipelago
What does your nginx config look like?Luminesce
@Luminesce Here's my nginx config gist.github.com/7d10a26e40aa4d8b68a1Archipelago
and ls /opt/local/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/Luminesce
It seems like you have two Ruby installs, one at /opt/local/ree, and one at /opt/local/ruby-enterprise-1.8.7-2010.01.Luminesce
C
8

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
Clarkclarke answered 20/6, 2011 at 10:35 Comment(9)
I've edited /etc/bashrc presume that the same file by another name? Running: which ruby, which rake and which gem return the /opt/local/ruby-enterprise-1.8.7-2010.01/... but 'gem env' still contains two gem paths the correct one and /root/.gem/ruby/1.8 :/Archipelago
the second one should not be a problem. have you tried to see if it works now?Clarkclarke
Yep, still get the same error as before 'no such file to load -- bundler' I've restarted nginx in case that was an issue.Archipelago
@andrea yep, 'bundler (1.0.15)' Could it be a permissions issue?Archipelago
look at the backtrace: it's still looking in /usr/lib/ruby/*. I don't know how you installed ruby and why you have at least 3 ruby environments without using RVMClarkclarke
updated my answer (see UPDATE2) with a drastic solution, but it should workClarkclarke
trust me, it's the best choice for ruby development. also, keep in mind that default ruby packages are a bit crappy: whatever linux packaging you pick, they're quite unusable :/Clarkclarke
RVM worked out very well, it does an extra layer of complexity, but it actually works!Archipelago
indeed, RVM is complex in order manage several ruby installs, but (imho) it's the best way to go.Clarkclarke

© 2022 - 2024 — McMap. All rights reserved.