Search code examples
ruby-on-railsrbenvcapistrano3centos7

VPS rbenv location directory is wrong when using Capistrano3


My Centos 7 has rbenv located in /root/.rbenv, but when I run cap production deploy:setup_config it searches rbenv inside /usr/local/rbenv.

Error Message

DEBUG [6a1407a4] Running /usr/bin/env [ -d /usr/local/rbenv/versions/2.2.0 ] as root@111.111.111.11
DEBUG [6a1407a4] Command: [ -d /usr/local/rbenv/versions/2.2.0 ]
DEBUG [6a1407a4] Finished in 6.403 seconds with exit status 1 (failed).
ERROR rbenv: 2.2.0 is not installed or not found in /usr/local/rbenv/versions/2.2.0

.bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

PATH=$PATH:$HOME/bin
export PATH
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)" 

Gemfile

# Use Capistrano for deployment
group :development do
  gem 'capistrano-rails'
  gem 'capistrano-bundler'
  gem 'capistrano-rbenv', github: "capistrano/rbenv"
end

Capfile

require 'capistrano/setup'
require 'capistrano/deploy'

require 'capistrano/rbenv'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
Dir.glob('lib/capistrano/*/*.rb').each { |r| import r }

Is rbenv supposed to be inside /usr/local/? Is something wrong in the configuration of the Capistrano? I've searched inside deploy.rb and the tasks inside lib/capistrano/*, but I found no reference of /usr/local/.

My references of the Capistrano setup are from this git.


Solution

  • Your problem in this line. You should specify :user value for rbenv_type variable because you have installed rbenv to user directory.