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!
Related
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'.
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;
I'm working on a rails project. With command "bundle exec rails s" I can fire up a local server, however, "bundle exec rails c" throws the following errors:
/Users/wh026399/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
from /Users/wh026399/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/wh026399/healthelife_web/vendor/bundle/gems/spring-1.6.2/lib/spring/commands.rb:33:in `<module:Spring>'
from /Users/wh026399/healthelife_web/vendor/bundle/gems/spring-1.6.2/lib/spring/commands.rb:4:in `<top (required)>'
from /Users/wh026399/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/wh026399/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/wh026399/healthelife_web/vendor/bundle/gems/spring-1.6.2/lib/spring/application.rb:77:in `preload'
from /Users/wh026399/healthelife_web/vendor/bundle/gems/spring-1.6.2/lib/spring/application.rb:143:in `serve'
from /Users/wh026399/healthelife_web/vendor/bundle/gems/spring-1.6.2/lib/spring/application.rb:131:in `block in run'
from /Users/wh026399/healthelife_web/vendor/bundle/gems/spring-1.6.2/lib/spring/application.rb:125:in `loop'
from /Users/wh026399/healthelife_web/vendor/bundle/gems/spring-1.6.2/lib/spring/application.rb:125:in `run'
from /Users/wh026399/healthelife_web/vendor/bundle/gems/spring-1.6.2/lib/spring/application/boot.rb:18:in `<top (required)>'
from /Users/wh026399/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/wh026399/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
Ruby version: 2.2.2
Rails version: 4.2.5
gem version: 2.5.2
Bundler version: 1.11.2
[UPDATE]: it turns out that commenting out "spring" in Gemfile will solve this issue.
Okay, I came across this after having the same problem as poster. His update suggesting that removing spring from the Gemfile helped me get on the right track. The problem for me was that I had introduced a new environment variables, but spring didn't pick it up. When you remove spring from the Gemfile, it prevents your app from using the spring process, but it doesn't actually stop the spring process so adding it back, doing bundle install, or anything else will still leave you with the same spring process running.
To see if this is likely your issue, you can check bin/spring status and see if spring is running in the background, and if it has been running for a while.
Solution (at least for me): restart spring
bin/spring stop
rails c
Have you tried gem update --system? You may need an updated version of rubygems.
if you use rvm set the default ruby version using following, so it will pickup the correct ruby version. you probably needs to run bundle install/gem install rails -v 4.2.5 after setting the default
rvm --default 2.2.2
Its weird with CentOS release 6.7 (Final) that unable to run console on stage.
Ruby-version => 2.0.0
Rails- version => 4.1
Once I do bin/rails c staging
/var/www/rails/Ixentech/releases/20151201150901/config/application.rb:7:in `<top (required)>': uninitialized constant Bundler (NameError)
from /home/carmatec/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
from /home/carmatec/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
from /home/carmatec/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:141:in `require_application_and_environment!'
from /home/carmatec/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:67:in `console'
from /home/carmatec/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/carmatec/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
from /home/carmatec/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:128:in `require'
from /home/carmatec/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from /home/carmatec/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from bin/rails:4:in `<main>'
as I completely check with
uninitialized-constant-bundler-nameerror
nameerror-uninitialized-constant-bundler
bin dir permission
and
constant-bundler-namee
but no luck !!!
These answer work with ubuntu 12.04 LTS but not with CentOS
release 6.7 (Final) Further, I checked Redmine as well.
Any help would be appreciate !!!
Try gem install bundler from the command line. Then you'll also want to bundle install from the project directory.
It looks like your system doesn't have "bundler" installed on it yet. Bundler is a dependency manager, once it's installed the bundle install command will install any other gems needed by your project (such as rails itself!).
Did you copy this project directory over from another computer, or git clone it there or something? Cause you'd need bundler installed to create a Rails app in the first place, normally.
Bundler isn't actually included with a ruby install, but you need it as the first thing for Rails, and much other modern ruby code. After installing ruby on a new machine (or starting fresh on a new machine that has ruby pre-installed) gem install bundler should always be the next step.
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?