简体   繁体   中英

Capistrano Could not locate Gemfile or .bundle/ directory?

I try to use Capistrano in my rails app on Ubuntu server , and run cap production deploy got this message:

Could not locate Gemfile or .bundle/ directory

here is my setting:

lock '3.4.0'

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

set :application, 'beaconserver'
set :repo_url, 'my git'

set :deploy_to, '/home/john/projects/beaconserver'
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") 


# rbenv 的設定
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

and I found a problem, in my setting:

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"

but my server doesn't exist /usr/local/rbenv/bin/rbenv

and there is /usr/local/rbenv/bin , I enter ls -al and shows:

drwxr-xr-x  2 root root 4096 Aug  6 08:50 .
drwxrwxrwx 11 root root 4096 Aug  6 09:03 ..
lrwxrwxrwx  1 root root   16 Aug  6 08:50 rbenv -> ../libexec/rbenv
-rwxr-xr-x  1 root root  724 Aug  6 08:50 ruby-local-exec

what does this mean? did it means that I change the /usr/local/rbenv/bin/rbenv position to some where like ../libexec/rbenv ?? maybe I do something wrong when I install rbenv, how can I fix it?

my gemfile:

  gem "capistrano", '3.4.0'
  gem "capistrano-rvm", '0.1.2'
  gem "capistrano-rbenv", '2.0.3', require: false # production server use rbenv
  gem "capistrano-rails", '1.1.3'
  gem 'capistrano-passenger', '0.1.1'
  gem 'capistrano-bundler','1.1.4'

capfile:

 require 'capistrano/rails'
 require 'capistrano/rbenv'
 require 'capistrano/bundler' 
 require 'capistrano/rails/assets'assets:precompile
 require 'capistrano/rails/migrations'
 require 'capistrano/passenger'

I think you should add execute path on the clear cache task.

Try this on the task :clear_cache :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM