Starting a Rails application on a new Nginx / Passenger installation causes the error "there is no such file to download - bundler / setup (LoadError)"

My VPS is running Ubuntu 12.04. I installed Nginx and Passenger on it, following these and these instructions , and in accordance with the instructions, I added the following lines to the http block of the /etc/nginx/nginx.conf file:

 passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini; passenger_ruby /usr/bin/ruby; 

and the following block (where I replaced the actual domain name with www.example.com ):

 server { listen 80; server_name www.example.com; root /srv/rails/myapp/public; passenger_enabled on; } 

The Rails application is located in the /srv/rails/myapp/ , which is also the directory for the Git project. The directory and all its contents are owned by the rails user. I made the directory writable in the world and, as the rails user, ran the following commands in it:

 git pull gem install bundler bundle install rake db:migrate RAILS_ENV=production bundle exec rake assets:precompile 

After that, the application starts in development mode: when I rails s command and open http://www.example.com//000 , the application works fine.

However, after doing all of the above and the sudo service nginx restart command, opening http://www.example.com gives the Passenger Error Screen, which says:

 no such file to load -- bundler/setup (LoadError) /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require' /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require' /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:245:in `run_load_path_setup_code' /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:348:in `running_bundler' /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:243:in `run_load_path_setup_code' /usr/share/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app' /usr/share/passenger/helper-scripts/rack-preloader.rb:158 

There's a lot of debugging output below this, and I'm not sure which one is useful, but here is an excerpt:

 Application root /srv/rails/myapp Environment (value of RAILS_ENV, RACK_ENV, WSGI_ENV and PASSENGER_ENV) production Ruby interpreter command /usr/bin/ruby User and groups uid=1001(rails) gid=1002(rails) groups=1002(rails) Environment variables SHELL = /bin/bash PASSENGER_DEBUG_DIR = /tmp/passenger.spawn-debug.XXXX2fPMPM USER = rails PWD = /srv/rails/myapp SHLVL = 0 HOME = /home/rails LOGNAME = rails SERVER_SOFTWARE = nginx/1.4.6 IN_PASSENGER = 1 PYTHONUNBUFFERED = 1 NODE_PATH = /usr/share/passenger/node RAILS_ENV = production RACK_ENV = production WSGI_ENV = production NODE_ENV = production PASSENGER_APP_ENV = production SERVER_PROTOCOL = HTTP/1.1 SCGI = 1 DOCUMENT_ROOT = /srv/rails/myapp/public QUERY_STRING = SERVER_NAME = www.example.com REMOTE_PORT = 49316 REMOTE_ADDR = [redacted] SERVER_PORT = 80 REQUEST_METHOD = GET SERVER_ADDR = [redacted] REQUEST_URI = / ... General Ruby interpreter information RUBY_VERSION = 1.8.7 RUBY_PLATFORM = x86_64-linux RUBY_ENGINE = nil RubyGems version = 1.8.15 

The application uses Ruby v2.0.0p353, while Passenger seems to use v1.8.7; I am not sure if this is due to this problem. (The Ruby used by the application lives in /home/rails/.rvm/rubies/ruby-2.0.0-p353/ .)

I was looking for other issues where Passengers will display this error, but nothing I've tried so far fixes the problem.

0
source share
2 answers

After several attempts, I refused to install nginx from Debian packages. I deleted it and also deleted my rubies and RVM, and then reinstalled everything following these instructions . The article tells how to install nginx using the command passenger-install-nginx-module , which comes with the passenger plane. It checks all the dependencies, and if it can continue, downloads and compiles nginx. By default, it is set to /opt/nginx/ .

This did not work. I also had to create an nginx startup script; instructions here . In addition, I had to edit the file /opt/nginx/conf/nginx.conf to add a link to my application, and also had to comment on the location / block. After all this and when you start sudo service nginx restart site will be up.

0
source

I really don't know if this will help, but try in the projects folder:

 which ruby # for example /home/rails/.rvm/rubies/ruby-2.0.0-p353/bin/ruby 

And that will deduce which ruby ​​your package is using. Put this value, replacing it:

 passenger_ruby /usr/bin/ruby; 

to that

 passenger_ruby /home/rails/.rvm/rubies/ruby-2.0.0-p353/bin/ruby 

end

change

this linux command:

 echo $MY_RUBY_HOME/bin/ruby 

may be the easiest and most correct way to find your ruby ​​binary.

+1
source

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


All Articles