unsorted
unsorted

Reputation: 3284

capistrano failure - where is cap deploy defined?

My run of cap deploy fails, and I think it's because of a formatting issue. Here's some output:

* executing "rm -rf /var/www/cap-deploy/socialmit/releases/20101215141011/log /var/www/cap-deploy/socialmit/releases/20101215141011/public/system /var/www/cap-deploy/socialmit/releases/20101215141011/tmp/pids &&\\\n      mkdir -p /var/www/cap-deploy/socialmit/releases/20101215141011/public &&\\\n      mkdir -p /var/www/cap-deploy/socialmit/releases/20101215141011/tmp &&\\\n      ln -s /var/www/cap-deploy/socialmit/shared/log /var/www/cap-deploy/socialmit/releases/20101215141011/log &&\\\n      ln -s /var/www/cap-deploy/socialmit/shared/system /var/www/cap-deploy/socialmit/releases/20101215141011/public/system &&\\\n      ln -s /var/www/cap-deploy/socialmit/shared/pids /var/www/cap-deploy/socialmit/releases/20101215141011/tmp/pids"

(Sorry for the formatting.)

The &&\\\n things look really fishy, and indeed dumping them into my console causes an output of `\n: command not found.

WHere is cap deploy defined? It looks like the issue has something to do with it being defined as a list of commands that aren't properly formatted, leading to the extraneous newline that is throwing stuff off. But I can't find the actual code for cap deploy to fix it. It doesn't seem to be an app-specific thing since it's not in my Capfile or any of the files referenced by the Capfile.

Upvotes: 0

Views: 968

Answers (2)

unsorted
unsorted

Reputation: 3284

The issue was that some user-defined tasks named after_symlink had to be renamed and invoked after the symlink using the after("deploy:symlink", "deploy:new_name") syntax:

problem:

namespace :deploy do
  desc "Symlink the upload directories"
  task :after_symlink do
    #run "mkdir -p #{shared_path}/uploads"
    run "ln -s #{deploy_to}/shared/db #{deploy_to}/#{current_dir}/db/link"
  end
end

error (actually a warning):

Deprecation Warning] Naming tasks with before_ and after_ is deprecated, please see the new before() and after() methods. (Offending task name was after_update_code)
[Deprecation Warning] Naming tasks with before_ and after_ is deprecated, please see the new before() and after() methods. (Offending task name was after_symlink)

correct way of doing it:

namespace :deploy do
  desc "Symlink the upload directories"
  task :link_db do
    #run "mkdir -p #{shared_path}/uploads"
    run "ln -s #{deploy_to}/shared/db #{deploy_to}/#{current_dir}/db/link"
  end
end

after("deploy:symlink", "deploy:link_db")

The issue with the \\\n business was a misdiagnosis on my part. Apparently that is executed fine.

Upvotes: 1

idlefingers
idlefingers

Reputation: 32067

The deploy task is defined in the gem here.

I'd say that's most likely not the problem though. What error is it raising when the deploy fails?

Upvotes: 0

Related Questions