Multiple simultaneous cargo build
s that depend on the same git repo can fail
#15267
Labels
A-git
Area: anything dealing with git
C-bug
Category: bug
S-needs-info
Status: Needs more info, such as a reproduction or more background for a feature request.
Problem
I am building multiple binaries from the same repo for
docker compose
services with docker RUN cache mounting. I depend on a crate as a git repository. When these services are built simultaneously, they share the same/usr/local/cargo
directory. The builds fail for all but the last service to finish downloading the dependency crate repo with the error "error: failed to get<dep crate>
as a dependency package of<my crate>
- I can share the full error if it's helpful.I have also reproduced this issue outside of docker by manually starting 2 builds in close succession, and I see the same behavior.
Steps
Manual repro
git
- the longer the dependency takes to download, the easier this will be to repro.sudo rm -rf /usr/local/cargo/git/ /usr/local/cargo/registry/ /usr/local/cargo/.crates* && cargo clean
cargo build
twice simultaneously - the intent here is to get the git clones to overlapExpected outcome: One
cargo build
does the clone, the other waits for it to finish and then uses the result, as with other dependency types.Actual outcome: Both
cargo build
s try to do the git clone at the same time, the first one ends up getting stomped on by the second one and so the firstcargo build
fails while the second one succeeds.Possible Solution(s)
In my docker case, I am able to switch the sharing type to
private
to spend some disk space to keep parallel builds. That looks something like this:Notes
No response
Version
The text was updated successfully, but these errors were encountered: