rust-analyzer: VSCode stuck on fetching cargo metadata, even without dependencies

The rust-analyzer in VSCode runs into an infinite loop of fetching cargo metadata in the latest version. It happened after I updated to Rust 1.88 and at first blamed the macros of my own project, but managed to reproduce the error on a VSCode Profile with only the rust-analyzer extension installed, in a freshly initialized folder. Edit: running rustup override set 1.87(or 1.80) does not fix it, so it’s most likely not a version problem.

rust-analyzer version: rust-analyzer version: 0.4.2525-standalone (2d518c73d9 2025-07-05) [/Users/USERNAME/.vscode/extensions/rust-lang.rust-analyzer-0.4.2525-darwin-arm64/server/rust-analyzer] (Pre-release has the same version and same problem)

rustc version: rustc 1.88.0 (6b00bc388 2025-06-23)

editor or extension: VSCode, latest version; rust-analyzer extension version: 0.3.2519

relevant settings: Only $RUSTC_WRAPPER=/Path/to/sccache.

repository link (if public, optional): Default rust hello world; cargo init

code snippet to reproduce:

mkdir test
cd test
cargo init
code .
(Then enter a profile with only the rust-analyzer)

I’m honestly not sure what I am doing wrong; I expect this to have to do something with something of my setup, else this should have happened to quite a few more people yet. I did record the logs for this:

https://pastebin.com/tfTWELhU (And yes, this also happens outside of the ~/Desktop folder.)

It’s making work on my Rust projects basically impossible because the CPU is caught up with fetching metadata and the results only show for a fraction of a second before the next fetch starts.

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 20 (14 by maintainers)

Most upvoted comments

I’ll try reproducing this with clippy

In the clippy repo with the following config

{
    "rust-analyzer.rustc.source": "discover",
    "rust-analyzer.linkedProjects": [
        "./Cargo.toml",
        "clippy_dev/Cargo.toml",
        "clippy_lints_internal/Cargo.toml",
        "lintcheck/Cargo.toml",
    ]
}

target/rust-analyzer/metadata/workspace/Cargo.lock is constantly cycling through the Cargo.lock contents of the 4 projects (we aren’t in a workspace)

We have

[build]
target-dir = "target"

In our config.toml which is perhaps related, but there is also a target dir for each linked project e.g. ./clippy_dev/target/rust-analyzer/metadata/workspace/Cargo.lock

same problem on nightly.

I can see that target/rust-analyzer/metadata/rustc-dev/Cargo.lock is constantly being updated

I’ll try it.

Trying releases: 0.3.2457 good 0.3.2490 good, 0.3.2509 good, 0.3.2519 good,

That’s weird. Can I even reproduce? 0.4.2525 good. That’s bad, that was the version I previously had problems with. Can I reproduce with the official version previously? (0.3.2527) Nope.

Lastly, does it work again on my larger projects? Yes, it works again. 0.4.2526. Weird.

I’ll recollect the details from above: rust-analyzer version: rust-analyzer version: 0.4.2525-standalone (2d518c73d9 2025-07-05) [/Users/USERNAME/.vscode/extensions/rust-lang.rust-analyzer-0.4.2525-darwin-arm64/server/rust-analyzer] rustc version: rustc 1.88.0 (6b00bc388 2025-06-23) I guess I set the CARGO_HOME??

Given that I can’t find anyone else with the same issue, I’ll blame it on a faulty install somehow.

After running through multiple versions of the rust-analyzer, I cannot reproduce the error, even with the same version. And also the same rustc version; nothing changed.

Closing as cannot reproduce.

Oh sorry, I misunderstood. Deleting the registry did not fix it sadly.

Do you have dependencies from some private git repositories in your workspace?

No, I get this issue right after cargo init without any changes to the code.

I guess this wasn’t happening before updating rust to 1.88.0, right? Then this happened after you just updated it, even though you didn’t update rust-analyzer?

Yes, that’s correct, if I remember correctly.

Could you let me know your rust-analyzer settings?

I am using a newly installed rust-analyzer extension, with no settings changed.

If it could help track down the issue, I could try a fresh VSCode install.