rust-lang / rust-lang/rust-analyzer
Constant "cargo check" invalidation
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
I searched around a lot, and there are other people reporting similar issues, but I think this stands alone because I've ruled out all the other mentioned issues AFAIK.
In short: every time I save, including after very minor changes, cargo check runs (expected) and checks all dependencies (unexpected) taking several minutes. To my knowledge this didn't always happen.
I run 1 instance of VS code, and I set
"rust-analyzer.cargo.extraEnv": {
"CARGO_TARGET_DIR": "/mnt/scratch/ra_cargo_target"
},
"rust-analyzer.check.extraEnv": {
"CARGO_TARGET_DIR": "/mnt/scratch/ra_cargo_target"
}
which is used only by rust-analyzer. I don't run cargo, or any other external processes on rust code. This happens when I make a change, save, then change the line very slight, and save again (i.e. at most a few seconds between invocations).
Here's a list of things people have suggested:
- Different RUSTFLAGS (nothing in my env var, but every run should be consistent since it's all a single RA process)
- Different pkgconfig env vars (single RA process, same as above)
- Background process invalidating things (not running cargo watch or other vs code instances)
- Sharing a cache with a different target (AFAIK cargo writes to different dirs for different targets, but again this is all a single RA process so unless it's invalidating itself I don't see how it could be invalidated)
FWIW the vs code workspace does have mixed targets - x86 and wasm, with one local package shared between them.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the repeated cargo check behavior through the rust-analyzer VS Code settings, using the shared x86 and wasm workspace and CARGO_TARGET_DIR. Trace the cargo/check invalidation path and verify that consecutive minor saves no longer rebuild unchanged dependencies.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, vscode
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100