rust-lang / rust-lang/rust-analyzer

Constant "cargo check" invalidation

Open
#16,570 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-support
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.