Skip to content

Renaming the project root dir invalidates compilation cache #37647

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions