[Ruby] [Error] Regarding rbenv: ruby 2.5.1 is not installedot ~ when executing automatic deployment

1 minute read


In this post, I got into an error when I ran auto-deploy, so I will share the contents.

error contents

[Deprecation Notice] Future versions of Capistrano will not load the Git SCM
plugin by default.To silence this deprecation warning, add the following to
your Capfile after `require "capistrano/deploy"`:

    require "capistrano/scm/git"
    install_plugin Capistrano::SCM::Git

00:00 rbenv:validate
      WARN rbenv: ruby 2.5.1 is not installed or not found in $HOME/.rbenv/versions/ruby 2.5.1 on

Make a hypothesis

1. require “capistrano/scm/git” It is hypothesized that there is an abnormality in the Capfile from the description of require ~.

**2. WARN rbenv: ruby 2.5.1 is not installed ~ ** It is hypothesized that ruby 2.5.1 is not installed from the description ruby 2.5.1 is not installed, and there is a difference in ver from the local environment. Is deploy.rb suspicious…?

Temporary verification Capfile

require "capistrano/setup"
require "capistrano/deploy"
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git

Dir.glob("lib/capistrano/tasks/*.rake").each {|r| import r}

No particular abnormality.

Temporary verification ver confirmation

I ran ruby -v in the local development environment and the production environment (EC2), but there was no problem.

Temporary verification deploy.rb


# config valid only for current version of Capistrano
Described the version of #capistrano. Continue to use fixed version and prevent troubles due to version change
lock '3.14.1'

# Used to display the Capistrano log
set :application,'chat-space'

# Specify which repository to pull the app from
set :repo_url,'[email protected]:ken-sasaki-222/chat-space.git'

# Specify a common directory to reference even if the version changes
set :linked_dirs, fetch(:linked_dirs, []).push('log','tmp/pids','tmp/cache','tmp/sockets','vendor/bundle','public/system', ' public/uploads')

set :rbenv_type, :user
set :rbenv_ruby,'ruby2.5.1' # Focus here

# Which public key to use for deployment
set :ssh_options, auth_methods: ['publickey'],
                  keys: ['~/.ssh/test_key.pem']

# File location with process number
set :unicorn_pid, -> {"#{shared_path}/tmp/pids/unicorn.pid"}

# Unicorn configuration file location
set :unicorn_config_path, -> {"#{current_path}/config/unicorn.rb"}
set :keep_releases, 5

# Description to restart Unicorn after the deployment process is completed
namespace :deploy do
  task :restart do

There seems to be no problem with ruby ver. I thought… The part specified by ver is ‘ruby 2.5.1’!

Correctly, “2.5.1” is OK! If you fix it.


# abridgement

set :rbenv_type, :user
set :rbenv_ruby, '2.5.1' # Focus here

# abridgement

Now when you run bndle exec cap production deploy in the local environment terminal Automatic deployment ran safely.