部署到生产服务器时出现此错误:

$ cap production deploy
    triggering load callbacks
  * ←[32m2013-02-16 00:06:00 executing `production'←[0m
    triggering start callbacks for `deploy'
  * ←[32m2013-02-16 00:06:00 executing `multistage:ensure'←[0m
  * ←[32m2013-02-16 00:06:00 executing `deploy'←[0m
  * ←[32m2013-02-16 00:06:00 executing `deploy:update'←[0m
 ** transaction: start
  * ←[32m2013-02-16 00:06:00 executing `deploy:update_code'←[0m
    updating the cached checkout on all servers
    ←[33mexecuting locally: "git ls-remote [email protected]:user/app.git
production"←[0m
    ←[2;37mcommand finished in 3350ms←[0m
  * ←[33mexecuting "if [ -d /var/www/app/shared/cached-copy ]; then cd /var/
www/app/shared/cached-copy && git fetch -q origin && git fetch --tags -q ori
gin && git reset -q --hard f736340ecbsadasd948234f370c9d2bb && git clean
 -q -d -x -f; else git clone -q [email protected]:user/app.git /var/www/app/shared/cached-copy && cd /var/www/app/shared/cached-copy && git checko
ut -q -b deploy f736340ecasdsadasf795761f370c9d2bb; fi"←[0m
    servers: ["x"]
Password:
    [x] executing command
 ** ←[31m[x :: out] error: cannot open .git/FETCH_HEAD: Permission d
enied←[0m
    ←[2;37mcommand finished in 570ms←[0m
*** [←[34mdeploy:update_code←[0m] ←[34mrolling back←[0m
  * ←[33mexecuting "rm -rf /var/www/app/releases/20130215230611; true"←[0m
    servers: ["x"]
    [x] executing command
    ←[2;37mcommand finished in 176ms←[0m
failed: "sh -c 'if [ -d /var/www/app/shared/cached-copy ]; then cd /var/www/
app/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin
&& git reset -q --hard f736340342af1bsad79453761f370c9d2bb && git clean -q
-d -x -f; else git clone -q [email protected]:user/app.git /var/www/app
o/shared/cached-copy && cd /var/www/app/shared/cached-copy && git checkout -
q -b deploy f736340ecb6af1bgaasd5549d2bb; fi'" on x
$

但这个错误并不重要,它只是告诉我gem文件/包安装有问题。
怎么可能得到一个更详细的错误日志,在那里我可以看到问题所在的确切位置。

最佳答案

看起来您已经用sudo运行了其中一个命令,这会导致对/var/www/app/shared/cached-copy/.git/FETCH_HEAD的权限错误,最简单的解决方法是清除整个目录:

sudo rm -rf /var/www/app/shared/cached-copy

如果其他目录重复出现此问题,请尝试:
sudo chown -R $USER: /var/www/app

10-07 19:48