Updated to version 2.1.2 Ruby, the passenger is still at 1.9.3

How do I upgrade the version of Ruby used by Passenger when I update Ruby and its Gemlist using RVM and Capistrano? What is the best way to check if my application uses the correct ruby ​​version and gemset?

I have a Rails application running on a Linode (Ubuntu) server, with NGinx and Passenger. Before he worked without any problems.

My application previously ran Ruby on Rails 3.2.16 with Ruby 1.9.3-p194

I use RVM to manage ruby ​​versions both locally and on the server. After I installed Ruby-2.1.2 and updated the main gems (bundler, nokogiri, etc.), I created my new gemset for my application.

In development (locally), I use Ruby 2.1.2, rails 3.1.19 (before moving to Rails 4) and the specific gemset for this project.

I changed my deploy.rb for Capistrano following integration with RVM-Capistrano gem

 require "rvm/capistrano" require "bundler/capistrano" set :user, "myusername" set :application, "myapp" set :deploy_to, "/home/#{user}/apps/#{application}" set :scm, :git set :repository, " git@github.com :myusername/#{application}.git" set :branch, "master" set :rvm_ruby_string, :local # use the same ruby as used locally for deployment set :rvm_autolibs_flag, "read-only" # more info: rvm help autolibs set :use_sudo, false set :deploy_via, :remote_cache set :keep_releases, 3 default_run_options[:pty] = true set :ssh_options, { :forward_agent => true } before 'deploy:setup', 'rvm:install_rvm' # install/update RVM before 'deploy:setup', 'rvm:install_ruby' # install Ruby and create gemset after "deploy:restart", "deploy:cleanup" after "deploy", "rvm:trust_rvmrc" namespace :deploy do task :start do ; end task :stop do ; end task :restart, :roles => :app, :except => { :no_release => true } do run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}" end # ... some more tasks for assets and symlinks end namespace :rvm do task :trust_rvmrc do run "rvm rvmrc trust #{release_path}" end end 

Then I launched cap deploy

I updated my web page and the passenger throws the following errors:

 It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run: bundle install ... Could not find rake-10.3.2 in any of the sources (Bundler::GemNotFound) /home/myusername/.rvm/gems/ ruby-1.9.3-p194@global /gems/bundler-1.5.3/lib/bundler/spec_set.rb:92:in `block in materialize' ... Ruby interpreter command /home/myusername/.rvm/gems/ruby-1.9.3-p194/wrappers/ruby 

Passenger seems to still be running Ruby-1.9.3, not Ruby-2.1.2. I am not sure if RVM-Capistrano has installed / updated the Ruby version and the corresponding gemset. I'm not sure what I missed?

EDIT: I checked nginx.conf as root user in /opt/nginx/conf/nginx.conf

At the top of the file I found

 ... http { passenger_root /home/myusername/.rvm/gems/ruby-1.9.3-p194/gems/passenger-4.0.37; passenger_ruby /home/myusername/.rvm/gems/ruby-1.9.3-p194/wrappers/ruby; ... server { listen 80; server_name XXX.XXX.XX.XX myapp.com www.myapp.com *.myapp.com; root /home/myusername/apps/myapp/current/public; passenger_enabled on; client_max_body_size 4G; } 

Does this mean that I need to change these lines using ruby-2.1.2? Is there a way to automate this change?

UPDATE 2: I changed nginx.conf

 http { passenger_root /home/myusername/.rvm/gems/ ruby-2.1.2@rails3.2 /gems/passenger-4.0.53; passenger_ruby /home/myusername/.rvm/gems/ ruby-2.1.2@rails3.2 /wrappers/ruby; 

and in my deploy.rb I explicitly say use gemset ruby-2.1.2@rails3.2

 set :rvm_ruby_string, " 2.1.2@rails3.2 " 

The application is working fine, Ruby Interpreter is still 1.9.3. I even printed the RUBY_VERSION constant on the admin page, and it displays 1.9.3

I do not understand...

thanks for the help

+5
source share
2 answers

You can use several versions of ruby ​​controlled by rvm if you are using Passenger 4 or higher.

Here you have links to manuals

http://rvm.io/integration/passenger
https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html
https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html

It looks like you need to run rvmsudo -s first to start installing / updating a passenger on your server

+2
source

You must run passenger-install-nginx-module from the new RVM context in order to actually install the new passenger module. More details here:

https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html#run_passenger_installer

Nginx differs from other web servers in that it does not support loadable modules. The only way to extend Nginx is to completely recompile it from the source. Since Phusion Passenger consists of some external executables plus the Nginx module, you must recompile Nginx when you first install Phusion Passenger, but also when upgrading Nginx itself or when upgrading the version of Phusion Passenger.

So, manually changing the nginx configuration is not enough, you must run the installation program for passengers, which should take care of the correct configuration of nginx (i.e. recompile what is needed). I usually use the Apache passenger module and always run the installer for passengers after the upgrade. Just run rvm use ruby-2.1.2@rails3.2 before running the installer.

+2
source

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


All Articles