Passenger with nginx: cannot load such file -- bundler/setup (LoadError)
Asked Answered
Z

3

6

There is only one version of Ruby installed, and I have run gem install bundler && bundle install.

nginx conf

passenger_root /root/.gem/ruby/2.1.0/gems/passenger-4.0.52;
passenger_ruby /usr/bin/ruby;
server {
    listen 80;
    server_name example.com;
    root /srv/http/myrailsapp/public;
    passenger_enabled on;
    rails_env development;
}

Error Log

cannot load such file -- bundler/setup (LoadError)
/usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/root/.gem/ruby/2.1.0/gems/passenger-4.0.52/lib/phusion_passenger/loader_shared_helpers.rb:263:in `block in run_load_path_setup_code'
/root/.gem/ruby/2.1.0/gems/passenger-4.0.52/lib/phusion_passenger/loader_shared_helpers.rb:366:in `running_bundler'
/root/.gem/ruby/2.1.0/gems/passenger-4.0.52/lib/phusion_passenger/loader_shared_helpers.rb:261:in `run_load_path_setup_code'
/root/.gem/ruby/2.1.0/gems/passenger-4.0.52/helper-scripts/rack-preloader.rb:100:in `preload_app'
/root/.gem/ruby/2.1.0/gems/passenger-4.0.52/helper-scripts/rack-preloader.rb:158:in `<module:App>'
/root/.gem/ruby/2.1.0/gems/passenger-4.0.52/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
/root/.gem/ruby/2.1.0/gems/passenger-4.0.52/helper-scripts/rack-preloader.rb:28:in `<main>'
Zina answered 29/9, 2014 at 8:38 Comment(0)
H
10

I have been solving similar issue.

My problem was in configuration of passenger_ruby /usr/bin/ruby; Which points to the incorrect version. My solution was to set the path to output of command which ruby

On the server I use rvm. But there are aslo other instalations of ruby.

At first try to test the environment. Go to the application directory and run passenger start. This will show you you, if the server is ready to run the app. Fix the errors...

If the message still says that

cannot load such file -- bundler/setup (LoadError)

run gem install bundler and re-check.

Then set up the path in NGINX to path from which ruby command and restart the appllication.

Hypertonic answered 22/1, 2015 at 13:6 Comment(1)
Worked like a charm!Corrasion
S
1

You need to change your passenger_root value. Like here in doc

For example my nginx config:

...
  passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
  passenger_ruby /usr/bin/ruby;
...
Salaidh answered 29/9, 2014 at 8:51 Comment(1)
passenger-config --root gave me same thing as passenger_root valueZina
M
0

The phusion passenger could not find the ruby path, see if the ruby path is correct, or if the symbolic link was removed in the server update or other reason.

CentOS 7 Ruby 2.6.3 Rbenv

which ruby
# ~/.rbenv/shims/ruby
sudo rm /usr/bin/ruby # old ruby
sudo ln -s ~/.rbenv/shims/ruby /usr/bin/ruby # 2.6.3
 /usr/bin/ruby -v 
# ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
sudo service nginx restart
Miltie answered 2/10, 2019 at 23:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.