没有rvm或rbenv的ruby升级后,Ruby版本不匹配

时间:2019-02-20 17:50:33

标签: ruby capistrano unicorn bluepill ruby-upgrade

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

/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

1 个答案:

答案 0 :(得分:1)

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

您是否检查了Gemfile中的ruby版本?它应该与您使用的红宝石版本匹配,并且您可能需要运行

bundle update

bundle install