Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo build will rebuild without code change #7692

Closed
longyn opened this issue Dec 10, 2019 · 7 comments · Fixed by #7751
Closed

Cargo build will rebuild without code change #7692

longyn opened this issue Dec 10, 2019 · 7 comments · Fixed by #7751
Labels
C-bug Category: bug

Comments

@longyn
Copy link

longyn commented Dec 10, 2019

Problem

Repeat cargo build , it rebuild sometimes. For example, wait for 20s between two build requests, it probably will rebuild.

Steps

  1. A hello world project, with a dependency.
serde = "1.0.103"
  1. run cargo build
cargo build

project is build without any error.

  1. Wait for 10s ~ 20s

  2. run cargo build again

cargo build
  1. see the build result, project rebuild again

  2. if not rebuild, try cargo build again later

Possible Solution(s)

Notes

Output of cargo version:

cargo: 
  cargo 1.39.0 (1c6ec66d5 2019-09-30)
os:
  Microsoft Windows [Version 10.0.18362.476]
toolchain:
  stable-i686-pc-windows-msvc
  stable-x86_64-pc-windows-msvc (default)
rustc:
  rustc 1.39.0 (4560ea788 2019-11-04)

output with

D:\project\rust\hello>cargo build
[2019-12-10T08:47:28Z DEBUG cargo::core::compiler::fingerprint] fingerprint at: D:\project\rust\hello\target\debug\.fingerprint\hello-0d49ef5d0be49544\bin-hello-0d49ef5d0be49544
[2019-12-10T08:47:28Z DEBUG cargo::core::compiler::fingerprint] old local fingerprints deps
[2019-12-10T08:47:28Z INFO  cargo::core::compiler::fingerprint] stale: changed "D:\\project\\rust\\hello\\src\\main.rs"
[2019-12-10T08:47:28Z INFO  cargo::core::compiler::fingerprint]           (vs) "D:\\project\\rust\\hello\\target\\debug\\.fingerprint\\hello-0d49ef5d0be49544\\dep-bin-hello-0d49ef5d0be49544"
[2019-12-10T08:47:28Z INFO  cargo::core::compiler::fingerprint]                FileTime { seconds: 13220441240, nanos: 504682200 } != FileTime { seconds: 13220441243, nanos: 338750900 }
[2019-12-10T08:47:28Z INFO  cargo::core::compiler::fingerprint] fingerprint error for hello v0.1.0 (D:\project\rust\hello)/Build/Target { name: "hello", doc: true, ..: with_path("D:\\project\\rust\\hello\\src\\main.rs", Edition2018) }
[2019-12-10T08:47:28Z INFO  cargo::core::compiler::fingerprint]     err: current filesystem status shows we're outdated
[2019-12-10T08:47:28Z DEBUG cargo::core::compiler::fingerprint] fingerprint at: D:\project\rust\hello\target\debug\.fingerprint\serde-8e9540ce95d30679\lib-serde-8e9540ce95d30679
[2019-12-10T08:47:28Z DEBUG cargo::core::compiler::fingerprint] fingerprint at: D:\project\rust\hello\target\debug\.fingerprint\serde-943ea1ad745afc66\run-build-script-build_script_build-943ea1ad745afc66
[2019-12-10T08:47:28Z DEBUG cargo::core::compiler::fingerprint] fingerprint at: D:\project\rust\hello\target\debug\.fingerprint\serde-5f92802e6d14b992\build-script-build_script_build-5f92802e6d14b992
   Compiling hello v0.1.0 (D:\project\rust\hello)
[2019-12-10T08:47:28Z DEBUG cargo::core::compiler::fingerprint] write fingerprint (bce88c867730445f) : D:\project\rust\hello\target\debug\.fingerprint\hello-0d49ef5d0be49544\bin-hello-0d49ef5d0be49544
    Finished dev [unoptimized + debuginfo] target(s) in 0.57s

D:\project\rust\hello>cargo build
[2019-12-10T08:47:30Z DEBUG cargo::core::compiler::fingerprint] fingerprint at: D:\project\rust\hello\target\debug\.fingerprint\hello-0d49ef5d0be49544\bin-hello-0d49ef5d0be49544
[2019-12-10T08:47:30Z DEBUG cargo::core::compiler::fingerprint] old local fingerprints deps
[2019-12-10T08:47:30Z INFO  cargo::core::compiler::fingerprint] fingerprint error for hello v0.1.0 (D:\project\rust\hello)/Build/Target { name: "hello", doc: true, ..: with_path("D:\\project\\rust\\hello\\src\\main.rs", Edition2018) }
[2019-12-10T08:47:30Z INFO  cargo::core::compiler::fingerprint]     err: unit dependency information changed
[2019-12-10T08:47:30Z INFO  cargo::core::compiler::fingerprint]   cause: new (serde/61d371068b15ded9) != old (serde/4da49df1afa923c9)
[2019-12-10T08:47:30Z DEBUG cargo::core::compiler::fingerprint] fingerprint at: D:\project\rust\hello\target\debug\.fingerprint\serde-8e9540ce95d30679\lib-serde-8e9540ce95d30679
[2019-12-10T08:47:30Z INFO  cargo::core::compiler::fingerprint] fingerprint error for serde v1.0.103/Build/Target { ..: lib_target("serde", ["lib"], "C:\\Users\\Frank Long\\.cargo\\registry\\src\\gitlab.com-5c4dd09064763be6\\serde-1.0.103\\src\\lib.rs", Edition2015) }
[2019-12-10T08:47:30Z INFO  cargo::core::compiler::fingerprint]     err: path to the compiler has changed
[2019-12-10T08:47:30Z DEBUG cargo::core::compiler::fingerprint] fingerprint at: D:\project\rust\hello\target\debug\.fingerprint\serde-943ea1ad745afc66\run-build-script-build_script_build-943ea1ad745afc66
[2019-12-10T08:47:30Z INFO  cargo::core::compiler::fingerprint] fingerprint error for serde v1.0.103/RunCustomBuild/Target { ..: custom_build_target("build-script-build", "C:\\Users\\Frank Long\\.cargo\\registry\\src\\gitlab.com-5c4dd09064763be6\\serde-1.0.103\\build.rs", Edition2015) }
[2019-12-10T08:47:30Z INFO  cargo::core::compiler::fingerprint]     err: unit dependency information changed
[2019-12-10T08:47:30Z INFO  cargo::core::compiler::fingerprint]   cause: new (build_script_build/d91329d12c3f6836) != old (build_script_build/55c509b8e1b25cbb)
[2019-12-10T08:47:30Z DEBUG cargo::core::compiler::fingerprint] fingerprint at: D:\project\rust\hello\target\debug\.fingerprint\serde-5f92802e6d14b992\build-script-build_script_build-5f92802e6d14b992
[2019-12-10T08:47:30Z INFO  cargo::core::compiler::fingerprint] fingerprint error for serde v1.0.103/Build/Target { ..: custom_build_target("build-script-build", "C:\\Users\\Frank Long\\.cargo\\registry\\src\\gitlab.com-5c4dd09064763be6\\serde-1.0.103\\build.rs", Edition2015) }
[2019-12-10T08:47:30Z INFO  cargo::core::compiler::fingerprint]     err: path to the compiler has changed
   Compiling serde v1.0.103
[2019-12-10T08:47:30Z DEBUG cargo::core::compiler::fingerprint] write fingerprint (d91329d12c3f6836) : D:\project\rust\hello\target\debug\.fingerprint\serde-5f92802e6d14b992\build-script-build_script_build-5f92802e6d14b992
[2019-12-10T08:47:30Z DEBUG cargo::core::compiler::fingerprint] write fingerprint (6fb3b4b1c6eec27) : D:\project\rust\hello\target\debug\.fingerprint\serde-943ea1ad745afc66\run-build-script-build_script_build-943ea1ad745afc66
[2019-12-10T08:47:39Z DEBUG cargo::core::compiler::fingerprint] write fingerprint (61d371068b15ded9) : D:\project\rust\hello\target\debug\.fingerprint\serde-8e9540ce95d30679\lib-serde-8e9540ce95d30679
   Compiling hello v0.1.0 (D:\project\rust\hello)
[2019-12-10T08:47:39Z DEBUG cargo::core::compiler::fingerprint] write fingerprint (d83b09c3bda6217) : D:\project\rust\hello\target\debug\.fingerprint\hello-0d49ef5d0be49544\bin-hello-0d49ef5d0be49544
    Finished dev [unoptimized + debuginfo] target(s) in 9.56s
  • Windows system process still update the file under build directory after cargo process exit

image

@longyn longyn added the C-bug Category: bug label Dec 10, 2019
@alexcrichton
Copy link
Member

The error there is err: path to the compiler has changed, do you have RUSTC specified or is rustc configured in some other nonstandard way?

@longyn
Copy link
Author

longyn commented Dec 11, 2019

@alexcrichton, I have some configuration for rustc.

  • Here is my environement value.
RUSTUP_DIST_SERVER=http://mirrors.ustc.edu.cn/rust-static
RUSTUP_UPDATE_ROOT=http://mirrors.ustc.edu.cn/rust-static/rustup
RUST_BACKTRACE=1
CARGO_HOME=%USERPROFILE%\.cargo
  • And config under %USERPROFILE%.cargo\config
# custom registry support via the `registry.index` configuration is being removed
[source.crates-io]
replace-with = 'ustc'

[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index"

[source.github]
registry = "https://github.com/rust-lang/crates.io-index"

[source.gitlab]
registry = "https://gitlab.com/integer32llc/crates.io-index"
  • After I commented github section, no rebuild trigger,
[source.crates-io]
replace-with = 'ustc'

[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index"

#[source.github]
#registry = "https://github.com/rust-lang/crates.io-index"

[source.gitlab]
registry = "https://gitlab.com/integer32llc/crates.io-index"

@alexcrichton
Copy link
Member

Thanks for the info! This looks like it may be a bug in Cargo's resolution of crates perhaps, and it definitely looks like source replacement may be the issue here. Do you have a standalone example that I could reproduce with locally perhaps?

@longyn
Copy link
Author

longyn commented Dec 13, 2019

Yes, here it is.

  • Configuration files, run "env_rust.bat" for rust environment setup, and put the config into %CARGO_HOME%
    cargo.zip
  • Project
    hello.zip

@Diggsey
Copy link
Contributor

Diggsey commented Dec 19, 2019

I think I may be seeing the same issue, although it could be different. In my case, after updating a single dependency, cargo did a full rebuild of all dependencies.

I created a gist of the commands I ran and the cargo output:
https://gist.github.com/Diggsey/2c43835aea0f88617ef784b2922fa79a

It appears to be a regression in behaviour because the same project did not use to exhibit this problem.

I'm not using source replacement, but I am using the [patch.xxx] option. Also of note is that two dependencies of this project do quite a bit of code generation from their build scripts, and it's one of these dependencies which I updated.

I'm also on windows, cargo 1.40.0-nightly (3ba5f2717 2019-10-22)

@ehuss
Copy link
Contributor

ehuss commented Dec 28, 2019

@Diggsey I don't see where the issue is in the output you showed. Can you file a new issue since it seems unrelated. It would help to have some kind of reproduction. I would suspect in your case when you ran cargo update it changed the features for some low-level crates like winapi which transitively affected many other crates.

@ehuss
Copy link
Contributor

ehuss commented Dec 28, 2019

Proposed fix in #7751.

The error there is err: path to the compiler has changed, do you have RUSTC specified or is rustc configured in some other nonstandard way?

@alexcrichton FYI, that log message was incorrect (see #7749), it was actually the source path was changing between different registries.

@bors bors closed this as completed in 801942b Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants