Skip to content

Renaming the project root dir invalidates compilation cache #3273

Closed
@alubbe

Description

@alubbe

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cargo-apiArea: cargo-the-library API and internal code issuesA-rebuild-detectionArea: rebuild detection and fingerprintingC-bugCategory: bugCommand-build

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions