Working tree already exists
Closed this issue · 4 comments
Using Capistrano 3.8.1 and capistrano-git-with-submodules 2.0.3 I cannot deploy, I get the following error:
fatal: working tree '/home/clients/*****/cap-submodule-debug/releases/20170528162342' already exists.
Clone of 'git@github.com:getkirby/kirby.git' into submodule path 'kirby' failed
It worked just fine with Capistrano 3.6.1 and latest capistrano-git-submodule-strategy.
I created a repository with the bare minimum code to reproduce the problem: https://github.com/LeBenLeBen/cap-submodule-debug
I was wondering if this could be linked to the fact I have an old version of Git (which I can’t update) on the remote? It’s 1.7.10.4.
Let me know if I can provide you any additional information that would help you debug this issue.
Full log:
bundle exec cap staging deploy
00:00 git:wrapper
01 mkdir -p /tmp
✔ 01 *****@***** 0.290s
Uploading /tmp/git-ssh-cap-submodule-debug-staging-leben.sh 100.0%
02 chmod 700 /tmp/git-ssh-cap-submodule-debug-staging-leben.sh
✔ 02 *****@***** 0.029s
00:00 git:check
01 git ls-remote git@github.com:LeBenLeBen/cap-submodule-debug.git HEAD
01 0cc52e3e6d7b99257a68c65f6abd610080705401 HEAD
✔ 01 *****@***** 1.471s
00:01 deploy:check:directories
01 mkdir -p /home/clients/*****/cap-submodule-debug/shared /home/clients/*****/cap-submodule-de…
✔ 01 *****@***** 0.029s
00:02 git:clone
The repository mirror is at /home/clients/*****/cap-submodule-debug/repo
00:02 git:update
01 git remote set-url origin git@github.com:LeBenLeBen/cap-submodule-debug.git
✔ 01 *****@***** 0.036s
02 git remote update --prune
02 Fetching origin
02 From github.com:LeBenLeBen/cap-submodule-debug
02 88d5004..0cc52e3 master -> master
✔ 02 *****@***** 1.457s
00:03 git:create_release
01 mkdir -p /home/clients/*****/cap-submodule-debug/releases/20170528162342
✔ 01 *****@***** 0.029s
02 git archive master | /usr/bin/env tar -x -f - -C /home/clients/*****/cap-submodule-debug/releases/20170528162342
✔ 02 *****@***** 0.033s
00:03 git:submodules:create_release
01 git reset --mixed --quiet master --
✔ 01 *****@***** 0.032s
02 git submodule update --init --checkout --recursive --quiet
02 fatal: working tree '/home/clients/*****/cap-submodule-debug/releases/20170528162342' already exists.
02 Clone of 'git@github.com:getkirby/kirby.git' into submodule path 'kirby' failed
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as *****@*****: git exit status: 1
git stdout: Nothing written
git stderr: fatal: working tree '/home/clients/*****/cap-submodule-debug/releases/20170528162342' already exists.
Clone of 'git@github.com:getkirby/kirby.git' into submodule path 'kirby' failed
SSHKit::Command::Failed: git exit status: 1
git stdout: Nothing written
git stderr: fatal: working tree '/home/clients/*****/cap-submodule-debug/releases/20170528162342' already exists.
Clone of 'git@github.com:getkirby/kirby.git' into submodule path 'kirby' failed
Tasks: TOP => git:submodules:create_release
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as *****@*****: git exit status: 1
git stdout: Nothing written
git stderr: fatal: working tree '/home/clients/*****/cap-submodule-debug/releases/20170528162342' already exists.
Clone of 'git@github.com:getkirby/kirby.git' into submodule path 'kirby' failed
** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:
DEBUG [b15750c5] Finished in 0.028 seconds with exit status 0 (successful).
INFO [a54f77ed] Running /usr/bin/env mkdir -p /home/clients/*****/cap-submodule-debug/releases/20170528162342 as *****@*****
DEBUG [a54f77ed] Command: cd /home/clients/*****/cap-submodule-debug/repo && ( export GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/git-ssh-cap-submodule-debug-staging-leben.sh" ; /usr/bin/env mkdir -p /home/clients/*****/cap-submodule-debug/releases/20170528162342 )
INFO [a54f77ed] Finished in 0.029 seconds with exit status 0 (successful).
INFO [e30f2799] Running /usr/bin/env git archive master | /usr/bin/env tar -x -f - -C /home/clients/*****/cap-submodule-debug/releases/20170528162342 as *****@*****
DEBUG [e30f2799] Command: cd /home/clients/*****/cap-submodule-debug/repo && ( export GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/git-ssh-cap-submodule-debug-staging-leben.sh" ; /usr/bin/env git archive master | /usr/bin/env tar -x -f - -C /home/clients/*****/cap-submodule-debug/releases/20170528162342 )
INFO [e30f2799] Finished in 0.033 seconds with exit status 0 (successful).
DEBUG [677e43b3] Running test -f /home/clients/*****/cap-submodule-debug/releases/20170528162342/.gitmodules as *****@*****
DEBUG [677e43b3] Command: ( export GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/git-ssh-cap-submodule-debug-staging-leben.sh" GIT_DIR="/home/clients/*****/cap-submodule-debug/repo" GIT_WORK_TREE="/home/clients/*****/cap-submodule-debug/releases/20170528162342" GIT_INDEX_FILE="/home/clients/*****/cap-submodule-debug/releases/20170528162342/TEMP_INDEX_20170528162342" ; test -f /home/clients/*****/cap-submodule-debug/releases/20170528162342/.gitmodules )
DEBUG [677e43b3] Finished in 0.042 seconds with exit status 0 (successful).
DEBUG [bdfbf821] Running if test ! -d /home/clients/*****/cap-submodule-debug/releases/20170528162342; then echo "Directory does not exist '/home/clients/*****/cap-submodule-debug/releases/20170528162342'" 1>&2; false; fi as *****@*****
DEBUG [bdfbf821] Command: if test ! -d /home/clients/*****/cap-submodule-debug/releases/20170528162342; then echo "Directory does not exist '/home/clients/*****/cap-submodule-debug/releases/20170528162342'" 1>&2; false; fi
DEBUG [bdfbf821] Finished in 0.036 seconds with exit status 0 (successful).
INFO [8cc51abc] Running /usr/bin/env git reset --mixed --quiet master -- as *****@*****
DEBUG [8cc51abc] Command: cd /home/clients/*****/cap-submodule-debug/releases/20170528162342 && ( export GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/git-ssh-cap-submodule-debug-staging-leben.sh" GIT_DIR="/home/clients/*****/cap-submodule-debug/repo" GIT_WORK_TREE="/home/clients/*****/cap-submodule-debug/releases/20170528162342" GIT_INDEX_FILE="/home/clients/*****/cap-submodule-debug/releases/20170528162342/TEMP_INDEX_20170528162342" ; /usr/bin/env git reset --mixed --quiet master -- )
INFO [8cc51abc] Finished in 0.032 seconds with exit status 0 (successful).
INFO [5d0179c5] Running /usr/bin/env git submodule update --init --checkout --recursive --quiet as *****@*****
DEBUG [5d0179c5] Command: cd /home/clients/*****/cap-submodule-debug/releases/20170528162342 && ( export GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/git-ssh-cap-submodule-debug-staging-leben.sh" GIT_DIR="/home/clients/*****/cap-submodule-debug/repo" GIT_WORK_TREE="/home/clients/*****/cap-submodule-debug/releases/20170528162342" GIT_INDEX_FILE="/home/clients/*****/cap-submodule-debug/releases/20170528162342/TEMP_INDEX_20170528162342" ; /usr/bin/env git submodule update --init --checkout --recursive --quiet )
DEBUG [5d0179c5] fatal: working tree '/home/clients/*****/cap-submodule-debug/releases/20170528162342' already exists.
DEBUG [5d0179c5] Clone of 'git@github.com:getkirby/kirby.git' into submodule path 'kirby' failed
State of the remote when the error occurs (as you can see, the kirby
folder exists at this point):
- shared
- releases
- - 20170528163020
- - - .gitignore
- - - .gitmodules
- - - Capfile
- - - Gemfile
- - - Gemfile.lock
- - - config
- - - - deploy.rb
- - - - deploy
- - - - - production.rb
- - - - - staging.rb
- - - index.html
- - - kirby
- - - TEMP_INDEX_20170528163020
- repo
- - refs
- - - heads
- - - tags
- - branches
- - hooks
- - - update.sample
- - - applypatch-msg.sample
- - - pre-rebase.sample
- - - pre-commit.sample
- - - pre-applypatch.sample
- - - prepare-commit-msg.sample
- - - commit-msg.sample
- - - post-update.sample
- - info
- - - exclude
- - description
- - HEAD
- - config
- - objects
- - - pack
- - - - pack-354f3c37bde6e4da6bdc912915f882a44f99d488.pack
- - - - pack-354f3c37bde6e4da6bdc912915f882a44f99d488.idx
- - - info
- - packed-refs
- - FETCH_HEAD
- - ORIG_HEAD
- - modules
I'm running into this same issue, also with an older version of git on the target host. @LeBenLeBen did you figure out a workaround for this?
Sadly my workaround for now is to use Capistrano 3.6.x with the other submodule strategy.
I too suspect that this has to do with the version of git on the server you’re deploying to.
In my case, using capistrano-git-with-submodules on a server with git 2.7.4 works fine, whereas on a server with git 1.7.9.5 it fails with the error message described in this issue.
(Caveat: These are two different projects I’m testing with, but as far as I can tell they use the same versions of Capistrano, capinstrano-git-with-submodules etc., and the deploy configuration is almost identical, too.)
Thanks for your feedback, I will see with the host to update Git then.