简体   繁体   中英

passenger-config not set ruby version from rvm default

I have upgraded ruby version from 2.3.1 to 3.0.2 and also done related changes. On server, after deployment, nginx server cant start and giving error for old version.

I have checked ruby version with login user in ubuntu and rvm list, new 3.0.2 version is set as default version.

Error log: 
App 7441 stdout:
App 7441 stdout:
[ E 2021-10-19 03:59:51.9761 5027/T49 age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /home/apprunner/application/current: An error occurred while starting up the preloader.
  Error ID: c6399257
  Error details saved to: /tmp/passenger-error-J6lyAl.html
  Message from application: You must use Bundler 2 or greater with this lockfile. (Bundler::LockfileError)
  /usr/local/rvm/gems/ruby-2.3.0@application/gems/bundler-1.11.2/lib/bundler/lockfile_parser.rb:72:in `warn_for_outdated_bundler_version'
  /usr/local/rvm/gems/ruby-2.3.0@application/gems/bundler-1.11.2/lib/bundler/lockfile_parser.rb:59:in `initialize'
  /usr/local/rvm/gems/ruby-2.3.0@application/gems/bundler-1.11.2/lib/bundler/definition.rb:61:in `new'
  /usr/local/rvm/gems/ruby-2.3.0@application/gems/bundler-1.11.2/lib/bundler/definition.rb:61:in `initialize'
  /usr/local/rvm/gems/ruby-2.3.0@application/gems/bundler-1.11.2/lib/bundler/dsl.rb:173:in `new'
  /usr/local/rvm/gems/ruby-2.3.0@application/gems/bundler-1.11.2/lib/bundler/dsl.rb:173:in `to_definition'
  /usr/local/rvm/gems/ruby-2.3.0@application/gems/bundler-1.11.2/lib/bundler/dsl.rb:11:in `evaluate'
  /usr/local/rvm/gems/ruby-2.3.0@application/gems/bundler-1.11.2/lib/bundler/definition.rb:24:in `build'
  /usr/local/rvm/gems/ruby-2.3.0@application/gems/bundler-1.11.2/lib/bundler.rb:120:in `definition'
  /usr/local/rvm/gems/ruby-2.3.0@application/gems/bundler-1.11.2/lib/bundler.rb:88:in `setup'
  /usr/local/rvm/gems/ruby-2.3.0@application/gems/bundler-1.11.2/lib/bundler/setup.rb:18:in `<top (required)>'
  /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:456:in `activate_gem'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:323:in `block in run_load_path_setup_code'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:461:in `running_bundler'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:322: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:156:in `<module:App>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'
[ E 2021-10-19 03:59:51.9814 5027/T7 age/Cor/Con/CheckoutSession.cpp:285 ]: [Client 1-25] Cannot checkout session because a spawning error occurred. The identifier of the error is c6399257. Please see earlier logs for details about the error.

Don't know why error is show version 2.3.0?

How to set ruby version to passenger from rvm?

passenger check ruby command gives two different output: Command: passenger-config about ruby-command

  1. With Sudo user (rvm command not detected):

 root@ip-:/usr/bin# passenger-config about ruby-command passenger-config was invoked through the following Ruby interpreter: Command: /usr/bin/ruby2.3 Version: ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu] To use in Apache: PassengerRuby /usr/bin/ruby2.3 To use in Nginx: passenger_ruby /usr/bin/ruby2.3 To use with Standalone: /usr/bin/ruby2.3 /usr/bin/passenger start The following Ruby interpreter was found first in $PATH: Command: /usr/bin/ruby Version: ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu] To use in Apache: PassengerRuby /usr/bin/ruby To use in Nginx: passenger_ruby /usr/bin/ruby To use with Standalone: /usr/bin/ruby /usr/bin/passenger start

  1. System user(login user where rvm command detected):

 current$ passenger-config about ruby-command Your RVM wrapper scripts are too old, or some wrapper scripts are missing. Please update/regenerate them first by running: rvmsudo rvm get stable && rvm reload && rvmsudo rvm repair all If that doesn't seem to work, please run: rvmsudo rvm wrapper ruby-3.0.2 --no-prefix --all

Please provide any clue, how to set passenger ruby default version or how to solve this error.

As passenger is designed to server multiple (Rails) applications on one webserver, there are config options per virtual host (actually per dirctory) to set the environment for each application.

see https://www.phusionpassenger.com/docs/references/config_reference/apache/ and https://www.phusionpassenger.com/docs/references/config_reference/nginx/

RVM installs wrappers for each installed ruby in ie ~/.rvm/wrappers/ruby-3.0.2/ruby and you can tell passenger to use this ruby for your application.

in an apache config, you can write:

<Directory "/path/to/you/rails/app">
  PassengerRuby "/home/your-user/.rvm/wrappers/3.0.2/ruby"
  RailsEnv production
</Directory>

passenger-config tells you what wrapper to use, but you must set the ruby environment first. My passenger-config outputs this comment:

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 about ruby-command'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM