cargo: Renaming the project root dir invalidates compilation cache
I was surprised to learn that renaming the project root dir invalidates the compilation cache. This is something that happens during every CI and deployment run, making it run quite a bit slower when none of the rust code was actually changed. Is this intentional / is there a way to keep the cache fresh when renaming the directory?
The behaviour can be reproduced as follows (stable 1.12.1):
/$ cargo new rrrrrr
Created library `rrrrrr` project
/$ cd rrrrrr/
/rrrrrr$ cargo build
Compiling rrrrrr v0.1.0 (file:///rrrrrr) <-- Code gets compiled
Finished debug [unoptimized + debuginfo] target(s) in 0.11 secs
/rrrrrr$ cargo build
Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs <-- Code does not re-compile
/rrrrrr$ cargo build
Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs <-- Code does not re-compile
/rrrrrr$ cd ..
/$ mv rrrrrr/ rrrrrr2/
/$ cd rrrrrr2/
/rrrrrr2$ cargo build
Compiling rrrrrr v0.1.0 (file:///rrrrrr2) <-- Code re-compiles
Finished debug [unoptimized + debuginfo] target(s) in 0.11 secs
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (11 by maintainers)
Dear @alexcrichton, Is incremental compilation data for the project sources stored inside the project dir? I think it should use relative paths for these cases. The cache also will be invalidated if you move the project dir to another place. I don’t like it. Is a fix hard enough?