Philip John Philip John - 5 months ago 43
Ruby Question

Capistrano Rails deploy Passenger error

I deployed my Rails application to my local IP address. After the successful deployment, when I opened the page in browser, I get the following error. I have been stuck with the following issue for sometime.

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

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:

Is this app supposed to be run as the deploy user?
Is this app being run on the correct Ruby interpreter? Below you will see which Ruby interpreter Phusion Passenger attempted to use.
-------- The exception is as follows: -------

Could not find rake-10.4.2 in any of the sources (Bundler::GemNotFound)
/home/deploy/.gem/ruby/2.2.2/gems/bundler-1.12.5/lib/bundler/spec_set.rb:95:in `block in materialize'
/home/deploy/.gem/ruby/2.2.2/gems/bundler-1.12.5/lib/bundler/spec_set.rb:88:in `map!'
...


I verified this stackoverflow link and tried the following things.


I did
bundle install
multiple times as
deploy
user.

I had 2 versions of rake installed,
11.1.2
and
10.4.2
. I purged
11.1.2
. Made sure this version is not there anywhere.

I see 2 ruby versions. 1.9.3 and 2.2.2. Not sure if this is the issue. I did not manually install 1.9.3. But I see the folders
/usr/local/src/ruby-1.9.3-p448
and
/opt/rubies/ruby-1.9.3-p448
. When I tried to remove 1.9.3, using
sudo apt-get remove ruby 1.9.3
I got the following result. In the end, I did not remove it as it was trying to remove
passenger
itself.


Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libghc-hxt-xslt-dev-9.1.1-9b3da' for regex '1.9.3'
Note, selecting 'ruby1.9.3' for regex '1.9.3'
Note, selecting 'libghc-hxt-xslt-prof-9.1.1-9b3da' for regex '1.9.3'
Note, selecting 'libghc-hxt-xslt-dev' instead of 'libghc-hxt-xslt-dev-9.1.1-9b3da'
Note, selecting 'libghc-hxt-xslt-prof' instead of 'libghc-hxt-xslt-prof-9.1.1-9b3da'
Package 'ruby1.9.3' is not installed, so not removed
The following packages will be REMOVED
libruby2.1 passenger passenger-dev ri ruby ruby-dev ruby-full ruby-rack ruby2.1 ruby2.1-dev


Any help related to this issue is appreciated.

EDIT: I see files related to rake 11.1.2 still

/home/deploy/myapp/vendor/cache/rake-11.1.2.gem
/home/deploy/myapp/vendor/cache/ruby/2.2.0/specifications/rake-11.1.2.gemspec
/home/deploy/myapp/vendor/cache/ruby/2.2.0/cache/rake-11.1.2.gem
/home/deploy/myapp/vendor/cache/ruby/2.2.0/gems/rake-11.1.2
/home/deploy/myapp/vendor/cache/ruby/2.1.0/specifications/rake-11.1.2.gemspec
/home/deploy/myapp/vendor/cache/ruby/2.1.0/cache/rake-11.1.2.gem
/home/deploy/myapp/vendor/cache/ruby/2.1.0/gems/rake-11.1.2
/home/deploy/.gem/ruby/2.2.2/doc/rake-11.1.2
/home/deploy/.gem/specs/api.rubygems.org%443/quick/Marshal.4.8/rake-11.1.2.gemspec
/var/lib/gems/2.1.0/doc/rake-11.1.2


Could this be the problem?

I share the Ruby Environment details below.

RubyGems Environment:
RUBYGEMS VERSION: 2.4.5
RUBY VERSION: 2.2.2 (2015-04-13 patchlevel 95) [x86_64-linux]
INSTALLATION DIRECTORY: /home/deploy/.gem/ruby/2.2.2
RUBY EXECUTABLE: /opt/rubies/ruby-2.2.2/bin/ruby
EXECUTABLE DIRECTORY: /home/deploy/.gem/ruby/2.2.2/bin
SPEC CACHE DIRECTORY: /home/deploy/.gem/specs
SYSTEM CONFIGURATION DIRECTORY: /opt/rubies/ruby-2.2.2/etc
RUBYGEMS PLATFORMS:
ruby
x86_64-linux
GEM PATHS:
/home/deploy/.gem/ruby/2.2.2
/opt/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0
GEM CONFIGURATION:
:update_sources => true
:verbose => true
:backtrace => false
:bulk_threshold => 1000
REMOTE SOURCES:
https://rubygems.org/
SHELL PATH:
/home/deploy/.gem/ruby/2.2.2/bin
/opt/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/bin
/opt/rubies/ruby-2.2.2/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games


Nginx conf file
/etc/nginx/nginx.conf
is as follows.

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# SSL Settings
##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

##
# Phusion Passenger config
##
# Uncomment it if you installed passenger or passenger-enterprise
##

passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /usr/bin/ruby;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}


Nginx sites-enabled default file

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

server_name 192.xxx.xxx.xxx;
passenger_enabled on;
rails_env prelive;
root /home/deploy/myapp/current/public;

# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

Answer

Well, I did the following three steps and it started working. These are from the comments of Зелёный. Seems like I had to restart the machine or something for the changes to reflect. I am not sure.

  1. Checked /etc/nginx/nginx.conf and make sure the value for passenger_ruby is the same as output of which ruby command
  2. Check if rake version is 10.4.2 by executing rake --version. Else purge all rake and install rake 10.4.2
  3. bundle install

After doing these, I restarted the machine and did cap prelive deploy and the application was up.

Comments