问题
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.
回答1:
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.
回答2:
On a related note, I ran into this issue when changing my DB connections file setup on one of my deploys.
In this case, the old structure had one shared file for DB settings, while the newer had two. Even though these were declared in the recipe, I was getting errors when automated deletion of older builds were being done.
To resolve, I just deleted the older builds, and ran the cap [server name] deploy
a few times to clear it out, and to verify this was no longer occurring. So far, it's been fine.
来源:https://stackoverflow.com/questions/24314972/capistrano-destination-path-already-exists-not-an-empty-directory