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

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;

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 i18n-0.7.0 in any of the sources (Bundler::GemNotFound)

I get the following error after installing plugins to Redmine on Ubuntu 16.04 LTS.
The website displays:
"We're sorry, but something went wrong. We've been notified about this issue and we'll take a look at it shortly."
The error is:
"Could not find i18n-0.7.0 in any of the sources (Bundler::GemNotFound)"
The log is:
App 7302 stdout:
App 7302 stdout:
[ 2017-05-18 17:18:04.7070 6519/7fc7b81af700 App/Implementation.cpp:287 ]: Could not spawn process for application /opt/redmine-3.3.3-0/apps/redmine/htdocs/: An error occured w hile starting up the preloader.
Error ID: 5031bd31
Error details saved to: /tmp/passenger-error.l3kNMa
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. To install your gems, please run:</p >
<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. Please check the following:</p>
<ol>
<li>Is this app supposed to be run as the <code>daemon</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>
</ol>
<p>-------- The exception is as follows: -------</p>
Could not find i18n-0.7.0 in any of the sources (Bundler::GemNotFound)
<pre> /opt/redmine-3.3.3-0/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.14.5/lib/bundler/spec_set.rb:87:in `block in materialize'
/opt/redmine-3.3.3-0/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.14.5/lib/bundler/spec_set.rb:80:in `map!'
/opt/redmine-3.3.3-0/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.14.5/lib/bundler/spec_set.rb:80:in `materialize'
/opt/redmine-3.3.3-0/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.14.5/lib/bundler/definition.rb:176:in `specs'
/opt/redmine-3.3.3-0/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.14.5/lib/bundler/definition.rb:235:in `specs_for'
/opt/redmine-3.3.3-0/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.14.5/lib/bundler/definition.rb:224:in `requested_specs'
/opt/redmine-3.3.3-0/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:118:in `block in definition_method'
/opt/redmine-3.3.3-0/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:19:in `setup'
/opt/redmine-3.3.3-0/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.14.5/lib/bundler.rb:100:in `setup'
/opt/redmine-3.3.3-0/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.14.5/lib/bundler/setup.rb:20:in `<top (required)>'
/opt/redmine-3.3.3-0/ruby/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require'
/opt/redmine-3.3.3-0/ruby/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
/opt/redmine-3.3.3-0/ruby/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
/opt/redmine-3.3.3-0/ruby/lib/ruby/gems/2.1.0/gems/passenger-5.0.6/lib/phusion_passenger/loader_shared_helpers.rb:278:in `block in run_load_path_setup_code'
/opt/redmine-3.3.3-0/ruby/lib/ruby/gems/2.1.0/gems/passenger-5.0.6/lib/phusion_passenger/loader_shared_helpers.rb:381:in `running_bundler'
/opt/redmine-3.3.3-0/ruby/lib/ruby/gems/2.1.0/gems/passenger-5.0.6/lib/phusion_passenger/loader_shared_helpers.rb:276:in `run_load_path_setup_code'
/opt/redmine-3.3.3-0/ruby/lib/ruby/gems/2.1.0/gems/passenger-5.0.6/helper-scripts/rack-preloader.rb:99:in `preload_app'
/opt/redmine-3.3.3-0/ruby/lib/ruby/gems/2.1.0/gems/passenger-5.0.6/helper-scripts/rack-preloader.rb:157:in `<module:App>'
/opt/redmine-3.3.3-0/ruby/lib/ruby/gems/2.1.0/gems/passenger-5.0.6/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
/opt/redmine-3.3.3-0/ruby/lib/ruby/gems/2.1.0/gems/passenger-5.0.6/helper-scripts/rack-preloader.rb:28:in `<main>'</pre>
[ 2017-05-18 17:18:04.7174 6519/7fc7b99f3700 age/Hel/Req/CheckoutSession.cpp:252 ]: [Client 4-1] Cannot checkout session because a spawning error occurred. The identifier of the error is 5031bd31. Please see earlier logs for details about the error.
What could be the issue?
I think that the plugin that I was trying to install is not compatible with the version of Redmine that I was running.
I did a full migration of a Redmine instance from AWS to a local server, and everything is working properly. I had the plugin installed on the AWS version, and after doing a migration to the local server, Redmine works, as well as the plugin.
I got the issue above after trying to install the plugin directly to the local server without doing the migration, but it works fine if I just migrate everything from AWS to the local server.
See this topic.

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?

Passenger, RoR + Apache Bundler:Gemnotfound

I'm trying to set up my own VPS (Ubuntu 14.04), and have almost succeeded (I hope!).
I'm using passenger, Rails and Apache. When I browse to my IP, I get a bundle GemError, though when I run bundle install on my machine it tells me it's using all gems.
The problem first occurred with the json gem, which is the first gem. When I manually added "gem json, 1.8.3" to my Gemfile, the error went to the second gem of the list, minitest.
There are two weird messages on top which might be the problem, but I do not really understand those messages:
Ignoring executable-hooks-1.3.2 because its extensions are not built. Try: gem pristine executable-hooks --version 1.3.2
Ignoring gem-wrappers-1.2.7 because its extensions are not built. Try: gem pristine gem-wrappers --version 1.2.7
Could not find minitest-5.6.1 in any of the sources (Bundler::GemNotFound)
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.10.4/lib/bundler/spec_set.rb:92:in `block in materialize'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.10.4/lib/bundler/spec_set.rb:85:in `map!'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.10.4/lib/bundler/spec_set.rb:85:in `materialize'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.10.4/lib/bundler/definition.rb:140:in `specs'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.10.4/lib/bundler/definition.rb:185:in `specs_for'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.10.4/lib/bundler/definition.rb:174:in `requested_specs'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.10.4/lib/bundler/environment.rb:18:in `requested_specs'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.10.4/lib/bundler/runtime.rb:13:in `setup'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.10.4/lib/bundler.rb:127:in `setup'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.10.4/lib/bundler/setup.rb:18:in `<top (required)>'
/usr/local/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/usr/local/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:399:in `activate_gem'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:277:in `block in run_load_path_setup_code'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:404:in `running_bundler'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:276:in `run_load_path_setup_code'
/usr/share/passenger/helper-scripts/rack-preloader.rb:99:in `preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:153: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>'
Passenger author here. This error usually means one of two things:
Your app isn't being run as the user that it's supposed to be run as. Please set passenger_user to explicitly specify a user.
Your app isn't being run with the Ruby interpreter that it's supposed to be run as. Please set passenger_ruby to explicitly set a path to the Ruby interpreter that is supposed to be used.
If all fails, try our new end-to-end deployment walkthrough. It should work guaranteed (assuming you are starting from scratch and using the latest Passenger version).

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