cannot load such file -- bundler/setup (LoadError) || deploy on Ubuntu 12.04 x32

23,627

Solution 1

You sure have some PATH issues. Inside the /etc/nginx/nginx.conf, for passenger, you should be pointing to the ruby version where bundler is installed.

passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /home/thomas/.rvm/wrappers/default/ruby;

You can check this with the command

$ which ruby

The output of that command should be the one you should enter for passenger_ruby

If you haven't installed bundler yet go ahead and run gem install bundler

Also make sure that you are setting the environment variable in your server block:

server {
  listen 80 default;
  server_name blog.wall2flower.me;
  root /var/www/blog/current/public;
  passenger_enabled on;
}

Solution 2

You need to genarate binstubs to fix the problem:

bundle install --binstubs

Solution 3

As karlingen notes, the issue is the result of PATH issues, however if you are using RVM, you will want to get your path to the correct ruby another way...

Best thing is to follow Passenger's own guide for finding this info:

https://www.phusionpassenger.com/library/config/nginx/reference/#setting_correct_passenger_ruby_value

Solution 4

try:

bundle exec passenger start ...
Share:
23,627
luotao
Author by

luotao

Random-oriented programming

Updated on July 09, 2022

Comments

  • luotao
    luotao almost 2 years

    I try to deploy my rails app with Nginx, passenger on Ubuntu 12.04 x32. after all things is done, I visit my rails app, but it tell me 'We're sorry, but something went wrong.'.

    then I cat /var/log/nginx/error.log, I find this lines:

    Message from application: cannot load such file -- bundler/setup (LoadError)
    /home/thomas/.rvm/rubies/ruby-2.0.0-  p643/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    /home/thomas/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:278:in `block in run_load_path_setup_code'
    /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:381:in `running_bundler'
    /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:276:in `run_load_path_setup_code'
    /usr/share/passenger/helper-scripts/rack-preloader.rb:99:in `preload_app'
    /usr/share/passenger/helper-scripts/rack-preloader.rb:157:in `<module:App>'
    /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
    /usr/share/passenger/helper-scripts/rack-preloader.rb:28:in `<main>'
    

    I use rvm and rbenv

    $ ruby -v
    ruby 2.0.0p643 (2015-02-25 revision 49749) [i686-linux]
    $ rbenv versions
    system
    * 2.0.0-p643 (set by /home/thomas/.rbenv/version)
    

    and I hava already installed bundler

    $ bundler -v
    Bundler version 1.9.2
    

    and here is my gem env:

    RubyGems Environment:
      - RUBYGEMS VERSION: 2.4.6
      - RUBY VERSION: 2.0.0 (2015-02-25 patchlevel 643) [i686-linux]
      - INSTALLATION DIRECTORY: /home/thomas/.rvm/gems/ruby-2.0.0-p643
      - RUBY EXECUTABLE: /home/thomas/.rvm/rubies/ruby-2.0.0-p643/bin/ruby
      - EXECUTABLE DIRECTORY: /home/thomas/.rvm/gems/ruby-2.0.0-p643/bin
      - SPEC CACHE DIRECTORY: /home/thomas/.gem/specs
      - SYSTEM CONFIGURATION DIRECTORY: /home/thomas/.rvm/rubies/ruby-2.0.0-p643/etc
      - RUBYGEMS PLATFORMS:
        - ruby
        - x86-linux
      - GEM PATHS:
         - /home/thomas/.rvm/gems/ruby-2.0.0-p643
         - /home/thomas/.rvm/gems/ruby-2.0.0-p643@global
      - GEM CONFIGURATION:
         - :update_sources => true
         - :verbose => true
         - :backtrace => false
         - :bulk_threshold => 1000
      - REMOTE SOURCES:
         - https://rubygems.org/
      - SHELL PATH:
         - /home/thomas/.rvm/gems/ruby-2.0.0-p643/bin
         - /home/thomas/.rvm/gems/ruby-2.0.0-p643@global/bin
         - /home/thomas/.rvm/rubies/ruby-2.0.0-p643/bin
         - /home/thomas/.rvm/bin
         - /home/thomas/.rbenv/bin
         - /home/thomas/.rbenv/shims
         - /home/thomas/.rbenv/bin
         - /usr/local/sbin
         - /usr/local/bin
         - /usr/sbin
         - /usr/bin
         - /sbin
         - /bin
         - /usr/games
    

    have someone experienced same problem? thanks

    update: my /etc/nginx/nginx.conf and /etc/nginx/sites-enabled/blog.conf: https://gist.github.com/wall2flower/b3f410317585a8803a27 https://gist.github.com/wall2flower/72316e8b437d654e7070

  • luotao
    luotao about 9 years
    I try: bundle exec passenger start RAILS_ENV=production, I get error info:gist.github.com/wall2flower/17d0ab44417aeb31aaa9
  • Łukasz Ostrowski
    Łukasz Ostrowski about 9 years
    try bundle exec passenger start -e production -d
  • luotao
    luotao about 9 years
    I have try, and now I can visited succed with example.com:3000. : D
  • Łukasz Ostrowski
    Łukasz Ostrowski about 9 years
    You should change it in /etc/nginx/sites-enabled/blog.conf server_name example.com; or simply comment this line
  • luotao
    luotao about 9 years
    phusionpassenger.com/documentation/… thanks your help, with above link, I have solved my problems : )
  • luotao
    luotao about 9 years
    thank your patient, I have solved my problem with this link: phusionpassenger.com/documentation/… : )
  • xusisme
    xusisme almost 3 years
    Thanks for saving my time