Capistrano Rails 部署乘客错误
Capistrano Rails deploy Passenger error
我将我的 Rails 应用程序部署到我的本地 IP 地址。部署成功后,当我在浏览器中打开页面时,出现以下错误。一段时间以来,我一直被以下问题困扰。
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!'
...
我验证了 this Whosebug link 并尝试了以下操作。
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
感谢任何与此问题相关的帮助。
编辑:我仍然看到与 rake 11.1.2 相关的文件
/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
这可能是问题所在吗?
我在下面分享 Ruby 环境详细信息。
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文件/etc/nginx/nginx.conf
如下
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 站点启用默认文件
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;
}
}
嗯,我做了以下三个步骤,它开始工作了。这些来自 Зелёный 的评论。好像我必须重新启动机器或其他东西才能反映更改。我不确定。
- 已检查
/etc/nginx/nginx.conf
并确保 passenger_ruby
的值与 which ruby
命令的输出相同
- 通过执行
rake --version
检查 rake 版本是否为 10.4.2
。否则清除所有 rake 并安装 rake 10.4.2
bundle install
完成这些后,我重新启动了机器并做了 cap prelive deploy
应用程序启动了。
我将我的 Rails 应用程序部署到我的本地 IP 地址。部署成功后,当我在浏览器中打开页面时,出现以下错误。一段时间以来,我一直被以下问题困扰。
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!'
...
我验证了 this Whosebug link 并尝试了以下操作。
I did
bundle install
multiple times asdeploy
user.I had 2 versions of rake installed,
11.1.2
and10.4.2
. I purged11.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, usingsudo 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 removepassenger
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
感谢任何与此问题相关的帮助。
编辑:我仍然看到与 rake 11.1.2 相关的文件
/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
这可能是问题所在吗?
我在下面分享 Ruby 环境详细信息。
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文件/etc/nginx/nginx.conf
如下
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 站点启用默认文件
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;
}
}
嗯,我做了以下三个步骤,它开始工作了。这些来自 Зелёный 的评论。好像我必须重新启动机器或其他东西才能反映更改。我不确定。
- 已检查
/etc/nginx/nginx.conf
并确保passenger_ruby
的值与which ruby
命令的输出相同 - 通过执行
rake --version
检查 rake 版本是否为10.4.2
。否则清除所有 rake 并安装 rake 10.4.2 bundle install
完成这些后,我重新启动了机器并做了 cap prelive deploy
应用程序启动了。