Cargo install triggering new compilation after cargo build

Hi folks. I'm studying Rust and decided to write a simple CLI in order to learn some core concepts. Here's the program I wrote.

One issue I'm facing is when I build my project with cargo build --release, code compiles, a binary is generated, everything is fine, but then when I run cargo install --path . --locked, it compiles my code again, even generating two different out dirs.

I tried the same steps in projects like hyperfine and the artifacts of cargo build are used instead of triggering a new compilation. What am I doing wrong?

Thanks in advance.

I can reproduce this problem, but I'm not sure what causes it. I notice the first thing that gets rebuilt is syn.

I tried running the Cargo commands with CARGO_LOG=debug and confirmed that it's rebuilding syn and other dependencies because it can't find their fingerprint files (which Cargo uses to determine if a previous build is up to date) because the metadata hash in the filename is different from the previous build:

[2021-01-14T03:37:16Z DEBUG cargo::core::compiler::fingerprint] fingerprint at: /home/mbrubeck/src/test/quist/target/release/.fingerprint/syn-09c6ad1100e314ea/run-build-script-build-script-build
[2021-01-14T03:37:16Z INFO  cargo::core::compiler::fingerprint] fingerprint error for syn v1.0.58/RunCustomBuild/TargetInner { ..: custom_build_target("build-script-build", "/home/mbrubeck/.cargo/registry/src/", Edition2018) }
[2021-01-14T03:37:16Z INFO  cargo::core::compiler::fingerprint]     err: failed to read `/home/mbrubeck/src/test/quist/target/release/.fingerprint/syn-09c6ad1100e314ea/run-build-script-build-script-build`
    Caused by:
        No such file or directory (os error 2)

However, I haven't figured out what is causing the hash to change, or why it happens when installing quist but not hyperfine.

Oh, shoot. :pensive:

I can work around it somehow but it's annoying nonetheless. Do you think it's a bug? Should I open an issue upstream?

I do think it might be a bug. It's probably worth filing a Cargo issue to figure it out.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.