3

Testing capistrano with a simple recipe.

$ cap deploy:setup
  * executing `deploy:setup'
  * executing "sudo -p 'sudo password: ' mkdir -p /u/apps/ [..]
    [..]

deploy:setup works as exprected.

However

$ cap deploy:check
  * executing `deploy:check'
  * executing "test -d /u/apps/[..]
    [..]

When running deploy:check I get the following error:

The following dependencies failed. Please check them and try again:
--> You do not have permissions to write to `/u/apps/
[..]
--> `/u/apps/app/shared is not writable [..]

It seems that capistrano is not using sudo while in deploy:check mode.

I don't get it!

While in deploy:setup the whole directory structure was created by capistrano without any issue?

Why capistrano doesn't use sudo as in deploy:check?

Marius Butuc
  • 17,781
  • 22
  • 77
  • 111
pl1nk
  • 1,952
  • 1
  • 13
  • 11

2 Answers2

2

I also ran into this issue and it turned out capistrano was creating all of the folders under the <user> group except for the shared folder. SSH onto your server and do a long listing ls -l. If you see - root - root - for the shared folder, you'll just need to update the permissions on the folder:

sudo chown <user> shared
sudo chgrp <user> shared
Dan Caddigan
  • 1,578
  • 14
  • 25
1

I ran into the same issue: the trick is to explicitly configure Capistrano not to use sudo.
You can turn that off in your deploy.rb file with:

set :use_sudo, false

If you need to use sudo, how about using the sudo DSL Action Invocation in your commands:

run "#{sudo} apachectl restart"
Community
  • 1
  • 1
Marius Butuc
  • 17,781
  • 22
  • 77
  • 111
  • In my case I need to use sudo. – pl1nk Mar 05 '13 at 19:41
  • If you need to use sudo, how about using: `run "#{sudo} apachectl restart"` – the [**sudo** DSL Action Invocation](https://github.com/capistrano/capistrano/wiki/2.x-DSL-Action-Invocation-Sudo)? – Marius Butuc Mar 05 '13 at 20:12
  • Where can I change this option (sudo) for the operations in deploy:check **not the ones assigned by me** (see my question) ? – pl1nk Mar 06 '13 at 13:36
  • Try something easier first: how about using `set :use_sudo, true` in your `deploy.rb`? – Marius Butuc Mar 07 '13 at 00:29
  • It's already there, that's how the deploy:setup created the folder structure. – pl1nk Mar 07 '13 at 13:04