【问题标题】:Ruby version mismatch after ruby upgrade without rvm or rbenv没有 rvm 或 rbenv 的 ruby​​ 升级后 Ruby 版本不匹配
【发布时间】:2019-02-20 17:50:33
【问题描述】:

我正在使用 bluepill 管理独角兽,在 ruby​​ 升级后独角兽启动失败并出现以下错误:

/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.17.3/lib/bundler/definition.rb:495:in `validate_ruby!': Your Ruby version is 2.1.4, but your Gemfile specified 2.3.7 (Bundler::RubyVersionMismatch)
    from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.17.3/lib/bundler/definition.rb:470:in `validate_runtime!'
    from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.17.3/lib/bundler.rb:101:in `setup'
    from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.17.3/lib/bundler/setup.rb:20:in `<top (required)>'
    from /usr/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /usr/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
E, [2019-02-20T10:42:13.897013 #10437] ERROR -- : reaped #<Process::Status: pid 12149 exit 1> exec()-ed

奇怪的是它只有在通过 capistrano 部署调用时才会失败。如果我在服务器上手动运行它,它运行良好。我尝试了各种方法,但似乎没有任何效果。

提前致谢。

运行独角兽的Bluepill配置:

Bluepill.application(APPLICATION_NAME) do |application|
  application.working_dir = "/var/apps/APPLICATION_NAME/current"

  process "unicorn" do
    start_command    "/usr/local/bin/bundle exec unicorn -c config/unicorn.rb -E qa -D"
    environment      ({

      "RAILS_ENV"  => "qa",
      "RACK_ENV"   => "qa"
    })
    pid_file         "/var/apps/APPLICATION/shared/pids/unicorn.pid"
    cache_actual_pid false
    stop_command     "kill -QUIT {{PID}}"
    restart_command  "kill -USR2 {{PID}}"

    start_grace_time   60.seconds
    stop_grace_time    20.seconds
    restart_grace_time 13.seconds

    checks :flapping, :times => 2, :within => 30.seconds, :retry_in => 7.seconds

    monitor_children do
      stop_command "kill -QUIT {{PID}}"

      checks :mem_usage, :every => 10.seconds, :below => 500.megabytes, :times => [3,4], :fires => :stop
      checks :cpu_usage, :every => 10.seconds, :below => 20, :times => [3,4], :fires => :stop
    end
  end
end

【问题讨论】:

  • 您是否在Gemfile 中指定了 ruby​​ 版本?
  • @zeitnot 是的,它是 2.3.7。
  • 这是一个 Rails 项目吗?
  • /usr/lib/ruby/site_ruby/2.1.0/ 是什么?添加代码,显示 blupill 如何运行 unicorn,以及触发错误的操作
  • @lacostenycoder - 这是旧的 ruby​​ 配置。使用 bluepill 配置更新了问题描述。

标签: ruby capistrano unicorn bluepill ruby-upgrade


【解决方案1】:

错误很明显:Your Ruby version is 2.1.4, but your Gemfile specified 2.3.7

您检查过 Gemfile 中的 ruby​​ 版本吗?它应该与您正在使用的 ruby​​ 版本匹配,并且您可能需要运行

bundle update

bundle install

【讨论】:

  • 嗨,我使用的是 ruby​​ 2.3.7,而且在任何地方都是一样的。以前是2.1.4,后来升级到2.3.7。
  • @vikram 你所说的“无处不在”是什么意思?
  • 表示它是系统范围内安装的 ruby​​ 版本。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-03-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-14
  • 1970-01-01
  • 2016-10-05
相关资源
最近更新 更多