Documented CARGO_HOME cache paths may result in rebuilding git dependencies #8845
Labels
A-caching
Area: caching of dependencies, repositories, and build artifacts
A-git
Area: anything dealing with git
A-rebuild-detection
Area: rebuild detection and fingerprinting
C-bug
Category: bug
Problem
When caching the paths suggested in the cargo guide Cargo Home, Caching the Cargo home in CI, git dependencies may end up getting rebuilt despite being present already in the cache.
This happens because git dependencies will get checked out from
.cargo/git/db
into.cargo/git/checkouts
, which crucially will set the checkouted files'mtime
to the current time instead of the time they were commited. As a result, cargo will get the impression that the files have changed even though they haven't.Steps
Notice
winapi
gets rebuilt, despite not having changed. Notice also that winapi's build.rs file changed its mtime timestamp.Possible Solution(s)
I see two possible solutions. Either this is considered "normal" and the documentation should be amended to recommend people to cache
.cargo/git/checkouts
, or this is a bug and cargo should reset the files'mtime
after checking them out from git. Git does track the files' mtime, so it's certainly possible to do this, but it must be done manually as a simplegit clone
/checkout/reset does not set the files' mtime.Notes
Output of
cargo version
: cargo 1.45.1 (f242df6 2020-07-22)The text was updated successfully, but these errors were encountered: