“no such file to load — bundler/setup” on Apache/P

2019-04-01 02:59发布

I'm trying to deploy a draft of my first Rails app. It works great on my local WEBRick server.

However, on my Ubuntu VPS running Apache2 & Passenger, when I navigate to the app in my browser, I get:

Error message:
no such file to load -- bundler/setup
Exception class:
LoadError

With the following backtrace:

0   /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb    36  in `gem_original_require'
1   /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb    36  in `require'
2   /home/user/public/foo.com/config/boot.rb    6   
3   /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb    36  in `gem_original_require'
4   /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb    36  in `require'
5   /home/user/public/foo.com/config/application.rb 1   
6   /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb    36  in `gem_original_require'
7   /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb    36  in `require'
8   /home/user/public/foo.com/config/environment.rb 2   
9   /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb    36  in `gem_original_require'
10  /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb    36  in `require'
11  config.ru   3   
12  /usr/lib/ruby/vendor_ruby/rack/builder.rb   51  in `instance_eval'
13  /usr/lib/ruby/vendor_ruby/rack/builder.rb   51  in `initialize'
14  config.ru   1   in `new'
15  config.ru   1   

The app was built with Ruby v1.9.3 (or so I thought), which I've installed on Ubuntu (in the app root, ruby -v returns ruby 1.9.3p286 (2012-10-12 revision 37165) [i686-linux]).

As per this question, I've run gem install bundle and bundle install in the app root. I've also imported the correct gemset from my local machine to the VPS app root.

As per this question, I attempted to change the gem set to /home/user/.rvm/gems/ruby-1.9.3-p286@foo (where foo is that name of the gemset in use), but this just made the backtrace longer.

Any help further troubleshooting this would be much appreciated!

EDIT: I finally got my app functioning by uninstalling Rails, RVM, Ruby (an RVM version) & Passenger before reinstalling Rails, Passenger & Ruby (but not RVM).

3条回答
我命由我不由天
2楼-- · 2019-04-01 03:37

Try setting GEM_HOME on your virtual host's config file:

<VirtualHost *:80>
  ServerName foo.com
  SetEnv GEM_HOME /home/user/.rvm/gems/ruby-1.9.3-p286
  DocumentRoot /home/user/public/foo.com/public
  <Directory /home/user/public/foo.com/public>
    AllowOverride all
    Options -MultiViews
  </Directory>
</VirtualHost>

The problem seems to be that when you execute bundle install it uses the rvm ruby whilst when you execute passenger it still uses the ruby 1.8

查看更多
萌系小妹纸
3楼-- · 2019-04-01 03:45

How to set the correct value

If you are not sure what value to set passenger_ruby to, then you can find out the correct value as follows.

First, find out the location to the passenger-config tool and take note of it:

    which passenger-config
    /opt/passenger/bin/passenger-config

Next, activate the Ruby interpreter (and if applicable, the gemset) you want to use. For example, if you are on RVM and you use Ruby 2.2.1, you may want to run this:

    rvm use 2.2.1

Finally, invoke passenger-config with its full path, passing --ruby-command as parameter:

    /opt/passenger/bin/passenger-config --ruby-command
    passenger-config was invoked through the following Ruby interpreter:
      Command: /usr/local/rvm/wrappers/ruby-1.8.7-p358/ruby
      Version: ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
      To use in Apache: PassengerRuby /usr/local/rvm/wrappers/ruby-1.8.7-   p358/ruby
      To use in Nginx : passenger_ruby /usr/local/rvm/wrappers/ruby-1.8.7-p358/ruby
      To use with Standalone: /usr/local/rvm/wrappers/ruby-1.8.7-p358/ruby /opt/passenger/bin/passenger start

    ## Notes for RVM users
    Do you want to know which command to use for a different Ruby interpreter? 'rvm use' that Ruby interpreter, then re-run 'passenger-config --ruby-command'.

The output tells you what value to set.

Now goto passenger.conf in /etc/apache2/mods-available directory and paste required lines shown above.

Now execute following commands and it worked for me,

    a2dismod passenger
    a2enmod passenger
    service apache2 restart
查看更多
爷、活的狠高调
4楼-- · 2019-04-01 03:55

Did you change the /etc/apache2/mods-available/passenger.conf to change the paths to ruby 1.9.3?

Don't forget the a2dismod passenger and a2enmod passenger once you do that.

查看更多
登录 后发表回答