Closed
Description
Problem
For convenience I have also uploaded the failing code here: https://github.com/bstrie/bindeperror3
For the following code:
# Cargo.toml
[package]
name = "mycrate"
version = "0.0.0"
edition = "2021"
[dependencies]
sha2 = "0.10.2"
mybindep = { path = "mybindep", artifact = "bin" }
// src/main.rs
use sha2::{Sha256, Digest};
fn main() {
let mut hasher = Sha256::new();
hasher.update(include_bytes!(env!("CARGO_BIN_FILE_MYBINDEP")));
println!("{:?}", hasher.finalize());
}
# mybindep/Cargo.toml
[package]
name = "mybindep"
version = "0.0.0"
edition = "2021"
fn main() {
println!("foo");
}
Let us first run the code:
> cargo run
Compiling typenum v1.15.0
Compiling version_check v0.9.4
Compiling cfg-if v1.0.0
Compiling cpufeatures v0.2.2
Compiling mybindep v0.0.0 (/home/ben/code/scrap/bindeperror3/mybindep)
Compiling generic-array v0.14.5
Compiling block-buffer v0.10.2
Compiling crypto-common v0.1.3
Compiling digest v0.10.3
Compiling sha2 v0.10.2
Compiling mycrate v0.0.0 (/home/ben/code/scrap/bindeperror3)
Finished dev [unoptimized + debuginfo] target(s) in 1.95s
Running `target/debug/mycrate`
[35, 165, 2, 6, 70, 200, 127, 252, 43, 208, 70, 63, 14, 19, 101, 135, 230, 79, 67, 17, 117, 166, 95, 151, 147, 22, 222, 242, 7, 48, 74, 56]
Observe what happens if we make a change to mybindep:
- println!("foo");
+ println!("bar");
And then run the code again:
> cargo run
Compiling mybindep v0.0.0 (/home/ben/code/scrap/bindeperror3/mybindep)
Finished dev [unoptimized + debuginfo] target(s) in 0.13s
Running `target/debug/mycrate`
[35, 165, 2, 6, 70, 200, 127, 252, 43, 208, 70, 63, 14, 19, 101, 135, 230, 79, 67, 17, 117, 166, 95, 151, 147, 22, 222, 242, 7, 48, 74, 56]
Observe that while mybindep has been rebuilt, mycrate has not been rebuilt. We see that the hashed output of the mybindep binary as printed by mycrate is exactly the same as the first time, confirming that mycrate has not been rebuilt to include the new build of mybindep.
Now, without making any changes, immediately run the command again:
> cargo run
Compiling mycrate v0.0.0 (/home/ben/code/scrap/bindeperror3)
Finished dev [unoptimized + debuginfo] target(s) in 0.23s
Running `target/debug/mycrate`
[152, 255, 186, 13, 42, 128, 123, 193, 51, 22, 206, 127, 175, 78, 6, 146, 219, 61, 6, 224, 22, 93, 29, 5, 174, 55, 223, 183, 92, 29, 92, 43]
Now we see that mycrate has been rebuilt, and the different hash confirms that my crate is now observing the changed mybindep.
cc @Byron
Version
cargo 1.61.0-nightly (109bfbd 2022-03-17)
release: 1.61.0-nightly
commit-hash: 109bfbd055325ef87a6e7f63d67da7e838f8300b
commit-date: 2022-03-17
host: x86_64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1m)
os: Pop!_OS 21.10 (impish) [64-bit]