Capistrano找不到Gemfile或.bundle /目录?

时间:2015-09-08 08:40:27

标签: ruby-on-rails capistrano ubuntu-14.04

我尝试在 Ubuntu服务器上的rails应用中使用 Capistrano ,然后运行cap production deploy获取此消息:

Could not locate Gemfile or .bundle/ directory

这是我的设置:

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

我在我的环境中发现了一个问题:

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"

但我的服务器不存在 / usr / local / rbenv / bin / rbenv

并且有 / usr / local / rbenv / bin ,我输入 ls -al 并显示:

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
这是什么意思?这是否意味着我将 / usr / local / rbenv / bin / rbenv 位置更改为 ../ libexec / rbenv ?也许我在安装rbenv时做错了什么,我该如何解决?

我的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'

1 个答案:

答案 0 :(得分:0)

我认为你应该在清除缓存任务上添加执行路径。

在任务: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