deployer
deployer copied to clipboard
Git subodules not working with `clone` strategy
Hey there,
Previously, there was a git_recursive option available in deploy:update_code, but that was removed in March :(
Why is this removed? Can it be restored?
Thanks in advance!
PS: some additional background info, I'm building a Laravel application using Laravel Modules where every module has its own repo. These need to be pulled upon deployment..
When using the update_code_strategy option clone, the .git directory is preserved. But when I then manually run git submodule update in a different task, I'm getting an error:
[production] run cd ***/releases/1 && (
# clone the submodules
git submodule init
git submodule update
)
[production] Submodule 'Modules/[MODULE-1]' (***/.dep/[MODULE-1].git) registered for path 'Modules/[MODULE-1]'
[production] Submodule 'Modules/[MODULE-2]' (***/.dep/[MODULE-2].git) registered for path 'Modules/[MODULE-2]'
[production] fatal: repository '***/.dep/[MODULE-1].git' does not exist
[production] fatal: clone of '***/.dep/[MODULE-1].git' into submodule path '***/releases/1/Modules/[MODULE-1]' failed
[production] Failed to clone 'Modules/[MODULE-1]'. Retry scheduled
[production] fatal: repository '***/.dep/[MODULE-2].git' does not exist
[production] fatal: clone of '***/.dep/[MODULE-2].git' into submodule path '***/releases/1/Modules/[MODULE-2]' failed
[production] Failed to clone 'Modules/[MODULE-2]'. Retry scheduled
[production] fatal: repository '***/.dep/[MODULE-1].git' does not exist
[production] fatal: clone of '***/.dep/[MODULE-1].git' into submodule path '***/releases/1/Modules/[MODULE-1]' failed
[production] Failed to clone 'Modules/[MODULE-1]' a second time, aborting
[production] fatal: repository '***/.dep/[MODULE-2].git' does not exist
[production] fatal: clone of '***/.dep/[MODULE-2].git' into submodule path '***/releases/1/Modules/[MODULE-2]' failed
[production] Failed to clone 'Modules/[MODULE-2]' a second time, aborting
[production] error in deploy.php on line 26:
[production] exit code 1 (General error)
Upvote & Fund
- We're using Polar.sh so you can upvote and help fund this issue.
- We receive the funding once the issue is completed & confirmed by you.
- Thank you in advance for helping prioritize & fund our backlog.
This is strange. Can you debug why clone is not enough?
Hey, when I simply clone the repo, the Modules/ folder only contains two empty folders (one for each module). Normally, running git submodule init and git submodule update clones those repos.
A simple git clone is not sufficient to checkout submodules (https://github.blog/2016-02-01-working-with-submodules/). Using update_code_strategy with archive will result in empty submodule folders too.
This is a real blocker when using submodules. There needs to be a git submodule update --init somewhere, but afaik this will not work with a bare repo.
Let’s add support for it via special option.
Like git_submodules.
This works for me when using clone update_code_strategy .
after('deploy:update_code', 'deploy:git:submodules');
task('deploy:git:submodules', function () {
$git = get('bin/git');
cd('{{release_path}}');
run("$git submodule update --init");
});
Today I also encountered the fact that cloning submodules was removed from v.7 🤔
@antonmedv Can we also support submodules for archive mode?
Possible solutions:
I'm currently setting up a new project with deployer and we're using a TYPO3-project with many, many submodules.
Yes, it should be
git clone --recursive
to get the submodules checked out.
Without the --recursive option the submodule directories will be empty.
The approach from @fnagel does not work for me:
[staging01] error in deploy.php on line 162:
[staging01] run cd /data/www/sites/xxxxxxxx.de/releases/3 && (/usr/bin/git submodule update --init)
[staging01] err fatal: Kein Git-Repository (oder irgendeines der Elternverzeichnisse): .git
[staging01] exit code 128 (Invalid exit argument)
ERROR: Task deploy:git:submodules failed!
I don't understand why this work for @fnagel.
Very very sad that the --recursice option has disappeared :(
With nested submodules I had to add '--recursive' on the end of @fnagel 's submodule update command so in full that line now reads:
run("$git submodule update --init --recursive");
Thanks to @fnagel for the workaround. It should be documented on the UPGRADE file.