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?
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/github.com-1ecc6299db9ec823/syn-1.0.58/build.rs", 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.