Capistrano 使用错误的发布路径

Capistrano using wrong release path

我的 deploy.rb 文件看起来像这样

  SSHKit.config.command_map[:rake] = "bundle exec rake"

  lock '3.2.1'

  set :application, 'foobar'
  set :scm, :git
  set :repo_url, 'git@bitbucket.org:xxxx/xxxx.git'

  set :deploy_via, "copy"
  set :ssh_options, { forward_agent: true }

  set :assets_roles, [:web]
  set :whenever_roles, [:cron]

  set :format, :pretty

  set :pty, true

  set :linked_files, fetch(:linked_files, []).push('config/database.yml')

  set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/assets', 'public/system', 'public/uploads')

  set :keep_releases, 5

  set :rvm_type, :user
  set :rvm_ruby_version, '2.2.3@xxxx'

  set :nvm_type, :user
  set :nvm_node, 'v0.12.4'
  set :nvm_map_bins, %w{node npm}
  set :nvm_roles, [:web]

  set :bundle_path, nil
  set :bundle_binstubs, nil
  set :bundle_flags, '--system'

  namespace :deploy do

    after :restart, :clear_cache do
      on roles(:app) do
        within current_path do
          with rails_env: fetch(:rails_env) do
            execute :rake, 'db:schema:load'
          end
        end
      end
    end

  end

但是当我尝试执行 cap production deploy 时出现以下错误

    DEBUG [56b32b4c] Running /usr/bin/env if test ! -d /var/www/omega/current; then echo "Directory does not exist '/var/www/omega/current'" 1>&2; false; fi as deploy@XX.XX.XXX.X
    DEBUG [56b32b4c] Command: if test ! -d /var/www/xxxx/current; then echo "Directory does not exist '/var/www/xxxx/current'" 1>&2; false; fi
    DEBUG [56b32b4c]    Directory does not exist '/var/www/xxxx/current'
    cap aborted!
    SSHKit::Runner::ExecuteError: Exception while executing as deploy@XX.XX.XXX.X: if test ! -d /var/www/xxxx/current; then echo "Directory does not exist '/var/www/xxxx/current'" 1>&2; false; fi exit status: 1

我不明白它出了什么问题,我已经花了很多时间来调试错误,但还没有成功。

默认情况下,Capistrano 会将您的应用程序部署到 /var/www/[application_name],正如您在 :application 中设置的那样。部署时,它会查看 /var/www/omega 是否存在。它没有,因此它失败了。

您可以覆盖它的部署位置:

set :deploy_to, '/my/deploy/dir'

出现这种情况的原因是,current 符号链接已失效。表示它指向的目录以某种方式被删除。

那么为什么 Capistrnao 命令会导致错误 Directory does not exists