passenger-config not set ruby version from rvm default - ruby-on-rails

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
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
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 i.e. ~/.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'.

Related

Passenger cannot load rbenv managed versions

A server has two users. deploy has sudo privileges, guest does not.
guest has an application that is migrating ruby versions (from 2.3.4 to 2.4.5).
Initially, after guest installs version 2.4.5 passenger cannot start because it does not find this version of ruby. deploy had to install it. However, hte next phase of starting up the server fails to load the application, while at the same time confirming that it is seeking the version of ruby within the deploy user's directories
Error: The application encountered the following error: cannot load such file -- bundler/setup (LoadError)
/home/deploy/.rbenv/versions/2.4.5/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/deploy/.rbenv/versions/2.4.5/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:363:in `activate_gem'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:221:in `block in run_load_path_setup_code'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:527:in `running_bundler'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:220:in `run_load_path_setup_code'
/usr/share/passenger/helper-scripts/rack-loader.rb:86:in `load_app'
/usr/share/passenger/helper-scripts/rack-loader.rb:116:in `block in <module:App>'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:380:in `run_block_and_record_step_progress'
/usr/share/passenger/helper-scripts/rack-loader.rb:115:in `<module:App>'
/usr/share/passenger/helper-scripts/rack-loader.rb:28:in `<module:PhusionPassenger>'
/usr/share/passenger/helper-scripts/rack-loader.rb:27:in `<main>'
passenger-config --ruby-command seems to be looking for the proper directory,
passenger-config was invoked through the following Ruby interpreter:
Command: /home/guest/.rbenv/versions/2.4.5/bin/ruby
Version: ruby 2.4.5p335 (2018-10-18 revision 65137) [x86_64-linux]
However,
rbenv exec gem environment gemdir
returns
/home/guest/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0
How can this be fixed?
The issue here relates to different users and ruby versions invoked.
passenger-config --ruby-command
returns the interesting passage, in this case:
To use in Nginx : passenger_ruby /home/guest/.rbenv/versions/2.4.5/bin/ruby
while the nginx/sites-enabled/relevant_application file does not need to have that invoked for a single user, this command becomes necessary with multiple users. Then restart nginx!

Could not find rake-11.3.0 on deployment (Capistrano Nginx Passenger)

Recently updated an old web app to Rails 4.2.7.1 and Ruby 2.3.1 (It was working with Rails 3 and Ruby 1.9).
App running on an nginx-pasenger server on production with rvm.
Updated RVM and ruby in production, and set new ruby version as
default.
Deployed with Capistrano.
The app is not working, from the nginx log:
[ 2016-12-01 07:00:34.0368 1509/7fbcbf7fe700 agents/HelperAgent/RequestHandler.h:2306 ]: [Client 20] Cannot checkout session because a spawning$
App 6899 stdout:
App 6899 stdout:
[ 2016-12-01 07:01:13.2625 1509/7fbccdf3b700 Pool2/Implementation.cpp:287 ]: Could not spawn process for application /home/deploy/porinstinto/c$
Error ID: 9864a1e8
Error details saved to: /tmp/passenger-error-NDJl0Z.html
Message from application: <p>It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. T$
<pre class="commands">bundle install</pre>
<p>If that didn't work, then the problem is probably caused by your application being run under a different environment than it's supposed to. $
<ol>
<li>Is this app supposed to be run as the <code>deploy</code> user?</li>
<li>Is this app being run on the correct Ruby interpreter? Below you will
see which Ruby interpreter Phusion Passenger attempted to use.</li>
<li>Please check whether the correct RVM gemset is being used.</li>
<li>Sometimes, RVM gemsets may be broken.
Try resetting them.</li>
</ol>
<p>-------- The exception is as follows: -------</p>
Could not find rake-11.3.0 in any of the sources (Bundler::GemNotFound)
<pre> /home/deploy/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler/spec_set.rb:92:in `block in materialize'
/home/deploy/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler/spec_set.rb:85:in `map!'
/home/deploy/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler/spec_set.rb:85:in `materialize'
/home/deploy/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler/definition.rb:132:in `specs'
/home/deploy/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler/definition.rb:177:in `specs_for'
/home/deploy/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler/definition.rb:166:in `requested_specs'
/home/deploy/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler/environment.rb:18:in `requested_specs'
/home/deploy/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler/runtime.rb:13:in `setup'
/home/deploy/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler.rb:121:in `setup'
/home/deploy/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler/setup.rb:17:in `<top (required)>'
/home/deploy/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require'
/home/deploy/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
/home/deploy/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:263:in `block in run_load_path_setup_code'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:366:in `running_bundler'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:261: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:in `<module:App>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:28:in `<main>'</pre>
[ 2016-12-01 07:01:13.2791 1509/7fbcbf7fe700 agents/HelperAgent/RequestHandler.h:2306 ]: [Client 20] Cannot checkout session because a spawning$
UPDATE
Running "Bundle" in production server I can see that rake-11.3.0 is installed.
Readed suggested link about gemsets.
It seems that all gems are instaled in gemset 2.3.1#default
Seems also, reading error log, that passenger is using ruby-2.1.3#global gemset, wich has no proper gems installed.
Now, I have to change passenger gemset config to use correct "default" gemset. Any help?
try with :
bundle exec rake 'option'
Issue resolved, it was a problem on Nginx-passenger config.
nginx.conf file was pointing to ruby 2.1.3 (a prev version of ruby I used) so I simply replaced this line with:
passenger_ruby /home/deploy/.rvm/wrappers/ruby-2.3.1/ruby;

Rails server works, Rails console does not. `require': cannot load such file -- bundler/setup (LoadError) -

I'm using rvm on mac osx 10.9.5:
rvm 1.26.11 (latest) by Wayne E. Seguin , Michal Papis [https://rvm.io/]
Current ruby version in RVM:
=* ruby-2.2.3 [ x86_64 ]
I'm not sure what exactly caused this behaviour, it could be that I updated homebrew.
I also tried to disable spring by removing it from the gemfile, no luck. Also note the paths in the stacktrace, for Spring it points to 2.1.3 instead of 2.2.3. What could be going on here ?
$ rails c
Ignoring libv8-3.16.14.13 because its extensions are not built. Try: gem pristine libv8 --version 3.16.14.13
Ignoring libv8-3.16.14.11 because its extensions are not built. Try: gem pristine libv8 --version 3.16.14.11
Ignoring oj-2.14.0 because its extensions are not built. Try: gem pristine oj --version 2.14.0
/Users/Laurens/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- bundler/setup (LoadError)
from /Users/Laurens/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/commands.rb:33:in `<module:Spring>'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/commands.rb:4:in `<top (required)>'
from /Users/Laurens/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/Laurens/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/application.rb:77:in `preload'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/application.rb:143:in `serve'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/application.rb:131:in `block in run'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/application.rb:125:in `loop'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/application.rb:125:in `run'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/application/boot.rb:18:in `<top (required)>'
from /Users/Laurens/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/Laurens/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'
$ rails s
=> Booting Thin
=> Rails 4.2.4 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on localhost:3000, CTRL+C to stop
After lots of trial and error, got it working by doing the following:
In my rails project folder there was an invisible file called
".bundle", I deleted this file, it somehow had references to 2.1.3 .
Ran bundle install
Ran spring stop
Ran spring binstub --all
(In the meanwhile I also updated my xcode, but not sure if this had any effect.)
After this, rails c worked without the pristine & bundle errors.
Just update spring to latest (1.6.4)
see
https://github.com/rails/spring/issues/456
for references
have you tried this command?
gem pristine --all
If it does not help, try this one:
rvm get stable
You should also call your rails console command in the context of the bundle:
bunde exec rails console

Passsenger with NGINX cannot load such file -- bundler/setup (LoadError)

I have a rails app deployed on debian 7 server, it was working till now.
I deploy code using mina, since my reposiory link has changed, i deleted project and updated repository details and pushed new code to server and restarted nginx.
SInce then i am getting this error:
Could not spawn process for application /opt/www/app.co/app:
An error occured while starting up the preloader.
Error ID: 6d901b8e
Error details saved to: /tmp/passenger-error-3HAg6Z.html
Message from application: cannot load such file -- bundler/setup (LoadError)
/home/deployer/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/home/deployer/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems
/core_ext/kernel_require.rb:54:in `require'
/usr/lib/ruby/vendor_ruby/phusion_passenger
/loader_shared_helpers.rb:263:in `block in run_load_path_setup_code'
/usr/lib/ruby/vendor_ruby/phusion_passenger
/loader_shared_helpers.rb:366:in `running_bundler'
/usr/lib/ruby/vendor_ruby/phusion_passenger
/loader_shared_helpers.rb:261: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:in `<module:App>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:28:in `<main>'
I am unable to resolve this load error.
Tried below as mentioned by others, but it didn't help
gem bundler install && bundle install
My app requires ruby-2.1.5
rvm list
rvm rubies
=* ruby-2.1.5 [ x86_64 ]
which ruby
/usr/bin/ruby
In /opt/nginx/conf/nginx.conf, i have :
passenger_root /var/lib/gems/1.9.1/gems/passenger-4.0.53;
passenger_ruby /home/deployer/.rvm/gems/ruby-2.1.5/wrappers/ruby;
Tried using default ruby in passenger_ruby as ruby -v gives 1.9.1
ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
But couldn't resolve.
Kindly help me in resolving this as early as possible.
It sounds like your app is being run under a user that you did not expect it to. Could you read Sandboxing apps with Unix user accounts (user switching) to learn how Passenger runs your app under different users, and see whether you can troubleshoot your issue with this knowledge?

rbenv passenger cannot load such file -- bundler/setup

My passenger is installed as a gem.
Nginx is installed by passenger-install-nginx-module.
There are 3 gemsets for ruby 2.1.1, the rubygemset rails4_1 is the correct one for this app.
Other posts show similar issues(1, 2, 3), but none of them resolves my problem.
[ 2014-09-29 14:29:17.1212 13182/7f32e5938700 Pool2/Implementation.cpp:287 ]: Could not spawn process for application /home/canoe/apps/app1: An error occured while starting up the preloader.
Error ID: b57602d4
Error details saved to: /tmp/passenger-error-jcmrkH.html
Message from application: cannot load such file -- bundler/setup (LoadError)
/home/canoe/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/canoe/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/canoe/.rbenv/versions/2.1.1/gemsets/rails4_1/gems/passenger-4.0.52/lib/phusion_passenger/loader_shared_helpers.rb:263:in `block in run_load_path_setup_code'
/home/canoe/.rbenv/versions/2.1.1/gemsets/rails4_1/gems/passenger-4.0.52/lib/phusion_passenger/loader_shared_helpers.rb:366:in `running_bundler'
/home/canoe/.rbenv/versions/2.1.1/gemsets/rails4_1/gems/passenger-4.0.52/lib/phusion_passenger/loader_shared_helpers.rb:261:in `run_load_path_setup_code'
/home/canoe/.rbenv/versions/2.1.1/gemsets/rails4_1/gems/passenger-4.0.52/helper-scripts/rack-preloader.rb:100:in `preload_app'
/home/canoe/.rbenv/versions/2.1.1/gemsets/rails4_1/gems/passenger-4.0.52/helper-scripts/rack-preloader.rb:158:in `<module:App>'
/home/canoe/.rbenv/versions/2.1.1/gemsets/rails4_1/gems/passenger-4.0.52/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
/home/canoe/.rbenv/versions/2.1.1/gemsets/rails4_1/gems/passenger-4.0.52/helper-scripts/rack-preloader.rb:28:in `<main>'
[ 2014-09-29 14:29:17.1372 13182/7f32e3814700 agents/HelperAgent/RequestHandler.h:2306 ]: [Client 20] Cannot checkout session because a spawning error occurred. The identifier of the error is b57602d4. Please see earlier logs for details about the error.
The passenger config in nginx,
passenger_root /home/canoe/.rbenv/versions/2.1.1/gemsets/rails4_1/gems/passenger-4.0.52;
passenger_ruby /home/canoe/.rbenv/versions/2.1.1/bin/ruby;
Some output:
$ bundle -v
Bundler version 1.6.2
Exporting GEM_HOME to the gemset rails4_1 prior to launching nginx could not resolve the problem.
Any solution?
Try installing the bundler gem globally.
This is most likely an environment variable problem. Notice that the error message mentions "Error details saved to: ...filename..."? Open that file to see whether there are any suggestions, and double check whether the environment variables are correct.

Resources