Search code examples
ruby-on-rails-4ubuntucapistranocapistrano3

Capistrano using wrong release path


My deploy.rb file looks like this

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

  lock '3.2.1'

  set :application, 'foobar'
  set :scm, :git
  set :repo_url, '[email protected]: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

But when I try to do cap production deploy I'm getting following error

    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 [email protected]
    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 [email protected]: if test ! -d /var/www/xxxx/current; then echo "Directory does not exist '/var/www/xxxx/current'" 1>&2; false; fi exit status: 1

I don't understand what's going wrong with it and I spent quite a lot time already to debug the error but haven't had any success yet.


Solution

  • The reason for that particular scenario was, the current symlink was dead. Means to which directory it was pointing that was somehow deleted.

    So why Capistrnao commands was causing error Directory does not exists.