Sinatra app on Passenger cannot find rack (using RVM)

I fought the staging server for this Sinatra app for two days. I'm very sad. The last pothole is the Ruby error passed by the passenger:

there is no such file to download - rack

The nginx.conf file shows which Ruby we use and where the 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 Ruby 1.9.2 is for us.

The vhost configuration includes:

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

and the rack file:

 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 suppose that Sinatra requires that which causes stance.

Pearls 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 the file in the RVM directory, judging by 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 do next? I am very stumped.

+4
source share
1 answer

It seems that the problem was related to the passenger_ruby configuration value. RVM provides a wrapper to configure the appropriate environment for this Ruby (including gems), so passenger_ruby should read

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

With this in place we seem to be working.

+3
source

Source: https://habr.com/ru/post/1345025/


All Articles