Ruby version mismatch after ruby upgrade without rvm or rbenv

741 views Asked by At

I am using bluepill to manage unicorn and after ruby upgrade unicorn start is failing with below error:

/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

The strange thing is it fails only when it is invoked via capistrano deployment. It runs fine if I run it manually on the server. I tried all sort of things but nothing seems to work.

Thanks in advance.

Bluepill confiuguration for running unicorn:

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

There are 1 answers

3
lacostenycoder On

The error is pretty clear: Your Ruby version is 2.1.4, but your Gemfile specified 2.3.7

Did you check the ruby version in your Gemfile? It should match the ruby version you're using and you'll likely need to run

bundle update

and

bundle install