cargo
cargo copied to clipboard
Cargo check (via rust-analyzer) forcing full rebuilds.
Problem
I'm running into the issues described in https://github.com/rust-lang/rust-analyzer/issues/17155, and first attributed to rust-analyzer, but have myself traced it down to cargo check.
Basically, cargo check seems to cause changes in file time stamps (that cargo build itself does not cause!), and this causes cargo build to fully rebuild unmodified (*-sys type) sub-crates and run build.rs, unnecessarily. This makes it pretty much impossible to run rust-analyzer.
Steps
If I edit and save a file in Zed, which runs rust-analyzer and through it, cargo check, a cargo build in the terminal will always be full (of the project and sub-crates, not of external dependencies).
If I edit the same file in a simple editor like joe, which doesn't know anything abour rust-analyzer and cargo, only the necessary components will be rebuilt by cargo build.
But I can even remove the editor out of the equation: If
- I run
cargo check, without even touch any file, - a subsequent
cargo buildwill be a full rebuild. - However, a
cargo buildfollowed by acargo build, will do nothing.
So there's something weird going on with cargo check.
Possible Solution(s)
No response
Notes
I suspect relationship to https://github.com/rust-lang/cargo/issues/10175 and https://github.com/rust-lang/cargo/issues/15073.
Version
cargo 1.89.0-nightly (056f5f4f3 2025-05-09)
release: 1.89.0-nightly
commit-hash: 056f5f4f3c100cb36b5e9aed2d20b9ea70aae295
commit-date: 2025-05-09
host: aarch64-apple-darwin
libgit2: 1.9.0 (sys:0.20.0 vendored)
libcurl: 8.7.1 (sys:0.4.80+curl-8.12.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 3.4.1 11 Feb 2025
os: Mac OS 15.4.1 [64-bit]