pjmorse
pjmorse

Reputation: 9304

Sinatra app on Passenger can't find Rack (using RVM)

I've been fighting with a staging server for this Sinatra app for two days. I'm getting pretty frustrated. The latest pothole is a Ruby error handed up by Passenger:

no such file to load -- rack

The nginx.conf file shows which Ruby we're using, and where Passenger is located:

passenger_root /usr/local/rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.5;
passenger_ruby /usr/local/rvm/rubies/ruby-1.9.2-p180/bin/ruby;

OK, so that's Ruby 1.9.2 for us.

The vhost configuration includes:

root /var/www/staging-proweb/current/rack/public;
passenger_enabled on;
rack_env          staging;

and the rackup file has:

require 'rubygems'
require 'sinatra'
require 'myapp1.rb'

run Sinatra::Application

which then sends us to the myapp1.rb file, which includes

require 'rubygems'
require 'rack'
require 'sinatra'

...and I assume the sinatra require is what's calling for rack.

The gem's there:

~$ which ruby
/usr/local/rvm/rubies/ruby-1.9.2-p180/bin/ruby
~$ gem list rack

*** LOCAL GEMS ***

rack (1.2.2)
rack-flash (0.1.1)

The error seems to be in a file in the RVM directory, judging from the first three lines of the stack trace:

0 /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb   36  in `require'
1 /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb   36  in `require'
2 /usr/local/rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.5/lib/phusion_passenger/rack/application_spawner.rb  219 in `load_rack_app'

What should I try next? I'm pretty stumped at this point.

Upvotes: 4

Views: 1146

Answers (1)

pjmorse
pjmorse

Reputation: 9304

It looks like the issue was with the passenger_ruby configuration value. RVM provides a wrapper to set up the appropriate environment for that Ruby (including the gems), so the passenger_ruby line should have read

    passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.2-p180/ruby;

With that in place, we seem to be up and running.

Upvotes: 3

Related Questions