【问题标题】:Passenger keeps looking for wrong ruby version乘客一直在寻找错误的 ruby​​ 版本
【发布时间】:2022-01-27 12:42:26
【问题描述】:

我将我的 ruby​​ 版本升级到 2.6.5。我使用 capistrano 将它部署到我的服务器。

但我的 nginx 日志是这样说的:

App 9470 output: /bin/sh: 1: exec: /home/deploy/.rvm/gems/ruby-2.3.1/wrappers/ruby: not found
[ E 2022-01-27 12:34:23.7336 9450/Tc age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /home/deploy/taddar/current: The application process exited prematurely.
  Error ID: d1f83ca0
  Error details saved to: /tmp/passenger-error-0KwZUf.html

[ E 2022-01-27 12:34:23.7393 9450/T9 age/Cor/Con/CheckoutSession.cpp:276 ]: [Client 1-1] Cannot checkout session because a spawning error occurred. The identifier of the error is d1f83ca0. Please see earlier logs for details about the error.

当我运行ruby -v 时,我得到了 2.6.5,但在上面你可以看到它正在寻找 2.3.1:

ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]

关于如何解决这个问题的任何想法?

在我的 deploy.rb 中,我设置了 ruby​​ 版本。

set :rvm_ruby_version, '2.6.5'

我的 nginx.config 看起来像:

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

events {
        worker_connections 768;
        # multi_accept on;
}

http {
        passenger_ruby /usr/bin/ruby2.6.5;

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        underscores_in_headers on;
        # 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 TLSv1.3; # 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_min_length 256;
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;

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

        include /etc/nginx/passenger.conf;

        ##
        # Virtual Host Configs
        ##

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

【问题讨论】:

  • nginx.config 中有什么?寻找phusionpassenger.com/library/config/nginx/reference/… 并设置正确的ruby 路径。
  • @razvans 感谢您的回复。我不是真正的开发人员,但如果你也指的是/etc/nginx/nginx.config,那它是空的。下面的看起来还可以吗?还是我需要其余的配置文件? ``` http { 乘客根 ...; # 默认使用 Ruby 2.1。乘客红宝石/usr/bin/ruby2.6.5; } ```
  • @razvans 我更新了我的问题以包含 nginx.config。我再次部署并重新启动了 nginx 和乘客,以防万一,但日志中仍然出现相同的错误。还有其他想法吗?
  • 启用站点的文件中是否对passenger_ruby 有任何引用?
  • 2 件事。 1 有可能在@razvans 提到的站点特定配置中有参考; 2. 我不确定你所说的“升级”红宝石是什么意思,但是这个系统似乎安装了 rvm(或者至少配置错误表明它确实如此),在这种情况下,你应该通过 rvm 安装红宝石,例如rvm install 2.6.5 然后引用rvm安装。

标签: ruby-on-rails passenger


【解决方案1】:

Bingo 成功了。感谢@razvans 和@engineersmnky 为我指明了正确的方向。

是的,我引用了passenger_ruby,但它在错误的位置。我必须去/etc/nginx/sites-available并添加passenger_ruby /path/to/ruby

要找出/path/to/ruby 是什么,请使用passenger-config about ruby-command 并使用Command 的值。

passenger-config about ruby-command
passenger-config was invoked through the following Ruby interpreter:
  Command: /home/deploy/.rvm/gems/ruby-2.6.5/wrappers/ruby

所以我是

server {
 ....
 passenger_ruby /home/deploy/.rvm/gems/ruby-2.6.5/wrappers/ruby

您可能想知道您对 ruby​​ 的任何其他引用,这样它们就不会相互冲突。一个有用的命令是:grep -rnw 'path' -e 'passenger_ruby'

这个文档对我帮助很大https://www.phusionpassenger.com/library/deploy/nginx/deploy/ruby/#determine_ruby_command

【讨论】:

  • 很高兴你能成功 +1
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-11-30
  • 1970-01-01
  • 1970-01-01
  • 2013-06-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多