Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Capistrano with wrong rbenv path?

I tried to use Capistrano on rails app. but I faced some problem: when I run cap production deploy:check, it seems ok

only wrong messages: does it matter?

DEBUG [a8c55ce2] Command: /usr/bin/env which passenger
DEBUG [a8c55ce2] Finished in 0.004 seconds with exit status 1 (failed).)

but when I run cap production deploy, get messages:

DEBUG [a71a7cfc] bash: /usr/local/rbenv/bin/rbenv: No such file or directory

and I search my server, I have no /usr/local/rbenv/bin/rbenv. but I have /usr/local/rbenv and I can use rails and deploy website for rails app, how can I find the right path on /usr/local/rbenv/bin/rbenv? or it is another problem?

here is my setting:

lock '3.4.0'

`ssh-add` # need this to make key-forwarding work

set :application, 'myapp'
set :repo_url, 'my ssh'

set :deploy_to, '/home/john/projects/myapp'
set :log_level, :debug
set :keep_releases, 5
set :linked_files, %w(config/database.yml config/secrets.yml)
set :linked_dirs, fetch(:linked_dirs, []).push("bin", "log", "tmp/pids", "tmp/cache", "tmp/sockets", "vendor/bundle", "public/system") 

set :rbenv_type, :user 
set :rbenv_ruby, "2.2.2"
set :rbenv_path, "/usr/local/rbenv"
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w(rake gem bundle ruby rails)
set :rbenv_roles, :all 

namespace :deploy do
  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
        execute :rake, 'cache:clear'
    end
  end
end

My folder

john@ip:/usr/local/rbenv$ ls -l
total 12
drwxr-xr-x 2 john admin 4096 Aug  5 16:44 shims
-rw-r--r-- 1 john admin    6 Aug  4 15:40 version
drwxr-xr-x 3 john admin 4096 Aug  4 15:33 versions

and I find 3 possible path with my plugin:

/home/john/.rbenv/plugins/ruby-build/bin
/home/john/.rbenv/versions/2.2.2/bin
/home/john/.rbenv/bin

I think it's my installization rbenv problem to cause this path problem.

like image 865
John Avatar asked Oct 20 '25 17:10

John


1 Answers

Ensure to include and configure correctly the capistrano-rbenv gem

In your Gemfile:

group :development do
  gem 'capistrano-rbenv'
end

In your Capfile:

require 'capistrano/rbenv'

Set the rbenv related variables in your config/deploy.rb:

# I assume your plugins directory is at /usr/local/rbenv/plugins
#    shims directory at /usr/local/rbenv/shims
#    and so on ... Adapt the following to your situation

set :default_env, {
    path: '/usr/local/rbenv/plugins/ruby-build/bin:/usr/local/rbenv/shims:/usr/local/rbenv/bin:$PATH',
    rbenv_root: '/usr/local/rbenv'
}
set :rbenv_roles, :all
set :rbenv_ruby, '2.2.2'
set :rbenv_ruby_dir, '/usr/local/rbenv/versions/2.2.2'
set :rbenv_custom_path, '/usr/local/rbenv'
like image 108
Benj Avatar answered Oct 23 '25 06:10

Benj