Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capistrano destination path already exists, not an empty directory

While deploying a Rails app with Capistrano on Ubuntu 14.04, I am getting the following error:

fatal: destination path '/var/www/APP-NAME/repo' already exists and is not an empty directory.


cf5a389e] Running /usr/bin/env [ -f /var/www/rd/repo/HEAD ] on LINODE-INSTANCE-IP
DEBUG[cf5a389e] Command: [ -f /var/www/rd/repo/HEAD ]
DEBUG[cf5a389e] Finished in 0.005 seconds with exit status 1 (failed).
DEBUG[8899b95c] Running /usr/bin/env if test ! -d /var/www/rd; then echo "Directory does not exist '/var/www/rd'" 1>&2; false; fi on LINODE-INSTANCE-IP
DEBUG[8899b95c] Command: if test ! -d /var/www/rd; then echo "Directory does not exist '/var/www/rd'" 1>&2; false; fi
DEBUG[8899b95c] Finished in 0.005 seconds with exit status 0 (successful).
INFO[fc5f524b] Running /usr/bin/env git clone --mirror GIT_REPO_URL /var/www/APP-NAME/repo on LINODE-INSTANCE-IP
DEBUG[fc5f524b] Command: cd /var/www/APP-NAME && ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/rd/git-ssh.sh /usr/bin/env git clone --mirror GIT-REPO-URL /var/www/APP-NAME/repo )
DEBUG[fc5f524b] fatal: destination path '/var/www/APP-NAME/repo' already exists and is not an empty directory.

Here are config files:

  • config/deploy/production.rb
  • config/deploy.rb

The only reason for this error I can find online is;

same host in more than one role, so that they're racing? For example I mean that you might have the same IP address defined as an :app role host more than once.

Which I guess isn't fitting with the above config files.

like image 281
red-devil Avatar asked Jun 19 '14 19:06

red-devil


1 Answers

I had the same problem. The reason is in double definition of the role and/or server. Try to remove

server 'SERVER-IP', user: 'USERNAME', roles: %w{app}

in production.rb and

role :app, "SERVER-IP"

in deploy.rb. The latter seems to be just simple syntax while the former - is extended one, so you in fact you declare roles twice (three time to be more precise: 2 in production.rb and 1 in deploy.rb). Hope it helps.

like image 126
Leger Avatar answered Nov 20 '22 11:11

Leger