3

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).

Community
  • 1
  • 1
amacy
  • 280
  • 6
  • 14

3 Answers3

2

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
C LOKESH REDDY
  • 230
  • 3
  • 9
1

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.

Rafael Martinez
  • 772
  • 3
  • 11
  • Thanks for your response. Based on a conversation in #rubyonrails last night, I do believe the problem is related to Passenger not being able to find the RVM version of Ruby. However, making the change you suggest in `/etc/apache2/mods-available/passenger.conf` file gives me a 500 error. There's no info in the apache error log about the error. – amacy Oct 27 '12 at 15:49
0

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

Rafael Martinez
  • 772
  • 3
  • 11
  • Setting the GEM_HOME for each virtual host separately also allows you to have different applications using different ruby and gems versions so it's the best place to define it. – Rafael Martinez Oct 26 '12 at 20:12
  • Thanks for the response. I made this addition & restarted Apache, but I'm still getting the same error with the same backtrace. – amacy Oct 26 '12 at 21:20
  • RubyRoot for passenger is set wrong, this setting should have no influence over passenger. – mpapis Oct 27 '12 at 05:24