tags:

views:

39

answers:

1

I am getting the followoing error when I try to do a deploy via a "deploy" user account.

  1782001..ae10d1b  master -> master
 ** transaction: start
  * executing `deploy:update_code'
    updating the cached checkout on all servers
    executing locally: "git ls-remote [email protected]:username/app_name.git master"
  * executing "if [ -d /var/www/app_name/shared/cached-copy ]; then cd /var/www/app_name/shared/cached-copy && git fetch -q origin && git reset -q --hard ae10d1bfe43820d8d69bbc92761a3f666cf56765 && git clean -q -d -x -f; else git clone -q [email protected]:username/app_name.git /var/www/app_name/shared/cached-copy && cd /var/www/app_name/shared/cached-copy && git checkout -q -b deploy ae10d1bfe43820d8d69bbc92761a3f666cf56765; fi"
    servers: ["173.230.158.13"]
    [173.230.158.13] executing command
 ** [173.230.158.13 :: out] error: cannot open .git/FETCH_HEAD: Permission denied
 ** 
    command finished
*** [deploy:update_code] rolling back
  * executing "rm -rf /var/www/app_name/releases/20100930022459; true"
    servers: ["173.230.158.13"]
    [173.230.158.13] executing command
    command finished
failed: "sh -c 'if [ -d /var/www/app_name/shared/cached-copy ]; then cd /var/www/app_name/shared/cached-copy && git fetch -q origin && git reset -q --hard ae10d1bfe43820d8d69bbc92761a3f666cf56765 && git clean -q -d -x -f; else git clone -q [email protected]:username/app_name.git /var/www/app_name/shared/cached-copy && cd /var/www/app_name/shared/cached-copy && git checkout -q -b deploy ae10d1bfe43820d8d69bbc92761a3f666cf56765; fi'" on 173.230.158.13

I can verify that I can do a "git clone" using the deploy account on the server and ssh to [email protected]

The same recipe works just fine if i specify "root" as the :user variable.

Here is my deploy.rb

http://pastie.org/1189919

Also, I am not sure what exactly does the :group variable does in this recipe.

drwxr-xr-x 14 deploy www-data   4096 2010-09-29 20:38 .
drwxr-xr-x 10 deploy www-data   4096 2010-09-29 20:38 ..
drwxr-xr-x  7 deploy www-data   4096 2010-09-29 13:13 app
-rwxr-xr-x  1 deploy www-data    240 2010-09-29 20:38 Capfile
drwxr-xr-x  5 deploy www-data   4096 2010-09-29 20:38 config
drwxr-xr-x  4 deploy www-data   4096 2010-09-29 20:38 db
drwxr-xr-x  2 deploy www-data   4096 2010-09-29 20:38 doc
drwxr-xr-x  9 deploy www-data   4096 2010-09-29 20:38 generate
drwxr-xr-x  8 deploy www-data   4096 2010-09-29 20:38 .git
-rwxr-xr-x  1 deploy www-data    156 2010-09-29 20:38 .gitignore
-rwxr-xr-x  1 deploy www-data    145 2010-09-29 20:38 .gitignore~
drwxr-xr-x  3 deploy www-data   4096 2010-09-29 20:38 lib
lrwxrwxrwx  1 deploy www-data     28 2010-09-29 20:38 log -> /var/www/voteable/shared/log
drwxr-xr-x  5 deploy www-data   4096 2010-09-29 20:38 public
-rwxr-xr-x  1 deploy www-data    457 2010-09-29 20:38 Rakefile
-rwxr-xr-x  1 deploy www-data  10011 2010-09-29 20:38 README
-rwxr-xr-x  1 deploy www-data     41 2010-09-29 20:38 REVISION
drwxr-xr-x  3 deploy www-data   4096 2010-09-29 20:38 script
drwxr-xr-x  6 deploy www-data   4096 2010-09-29 20:38 test
drwxr-xr-x  2 deploy www-data   4096 2010-09-29 20:38 tmp
-rwxr-xr-x  1 deploy www-data 810605 2010-09-29 20:38 uninstall
drwxr-xr-x  3 deploy www-data   4096 2010-09-29 13:13 vendor
+1  A: 

You need to make sure that you own .git so you should never do a checkout as root or you're going to run into this problem.

chmod -R ug+rw .git will fix the problem this time but you have to be diligent about keeping your coworkers from doing manual git pulls or work on setting up group permissions correctly.

Chuck Vose
Who is "you" in you own .git. the deploy account? Please see this other post of the same/similar problem as well.. may be related http://stackoverflow.com/questions/3827331/strange-ssh-issues-with-github
badnaam
You is your deploy account. If you do an `ls -la` on your .git/FETCH_HEAD you'll see that it's owned by root. So you'll either have to chown it to the deploy user, or chmod it so the deploy user can edit it.
Chuck Vose
yYou are absolutely correct. on that note..I updated the OP with the permission on my /www/var/app directory. Is that what it should look like or should www-data own it? I am very unclear about who should own this directory www-data or deploy
badnaam
also my deploy account is in "nogroup" is that the way it should be?
badnaam
probably want to make it www-data instead of nogroup. How about an upvote and an accepted answer if this worked?
Chuck Vose
No, that didn't work. I added deploy user to www-data group. Updated the OP with the permission on .git directory. still the same error
badnaam
wait a minute..it did work. can you please verify that the permission on the app directory is correct? I do owe you many votes up :)
badnaam
Looks great badnaam :)
Chuck Vose