rust-analyzer: Rust-analyzer VSCode plugin stuck while fetching

Rust-analyzer stopped working for me a few days ago. I think it was after upgrading to the latest plugin version. Rust-analyzer shows: “Fetching” with a spinner indefinitely. Sometimes I have gotten it to show “Fetching: metadata”.

I can replicate this in an empty project just after running cargo init mytestproject.

I have tried these steps:

  • Downgrading to the previous version of the plugin: this first failed because it would never download the binary, it would just show something like “binary for XXX is not downloaded”, but clicking the button did nothing. I downloaded the binary for that version manually and pointed the config to use it and that worked, but it gets stuck in the same way.
  • I’ve deleted ~/.cargo/registry and ~/.cargo/git.
  • I’ve made sure rust is up-to-date: rustup update.
  • I have removed all my rust-analyzer specific settings from vscode.
  • I’ve checked the rust-analyzer logs. They don’t seem to show anything weird. The latest messages for the various logs are:
[DEBUG lsp_server::msg] > {"jsonrpc":"2.0","method":"$/progress","params":{"token":"rustAnalyzer/Fetching","value":{"kind":"begin","title":"Fetching"}}}
[DEBUG lsp_server::msg] < {"jsonrpc":"2.0","id":1,"result":null}
[INFO rust_analyzer::main_loop] handle_event(Response(Response { id: RequestId(I32(1)), result: None, error: None }))
[Trace - 11:52:16 AM] Received request 'window/workDoneProgress/create - (1)'.
Params: {
    "token": "rustAnalyzer/Fetching"
}


[Trace - 11:52:16 AM] Sending response 'window/workDoneProgress/create - (1)'. Processing request took 0ms
No result returned.


[Trace - 11:52:16 AM] Received notification '$/progress'.
Params: {
    "token": "rustAnalyzer/Fetching",
    "value": {
        "kind": "begin",
        "title": "Fetching"
    }
}
INFO [6/23/2021, 11:52:16 AM]: PersistentState: {
  lastCheck: undefined,
  nightlyReleaseId: undefined,
  serverVersion: undefined
}
INFO [6/23/2021, 11:52:16 AM]: Using server binary at /home/arong/Downloads/rust-analyzer-x86_64-unknown-linux-gnu
  • I have tried to run the analysis-stats command, and it seems to work ok (except for some performance counters):
Failed to create perf counter: Operation not permitted (os error 1)
Database loaded:     552.02ms
Failed to create perf counter: Operation not permitted (os error 1)
  crates: 1, mods: 1, decls: 1, fns: 1
Item Collection:     1.26s
Failed to create perf counter: Operation not permitted (os error 1)
  exprs: 10, ??ty: 0 (0%), ?ty: 0 (0%), !ty: 0
Inference:           625.89ms
Total:               1.89s

I’m lost as to how to debug this further. Any suggestions about where to look would be helpful.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 22 (6 by maintainers)

Most upvoted comments

I also encountered a similar problem, my solution is rm -rf ~/.cargo/.package-cache then restarted vscode and it returned to normal

Tried to isolate the extension which causes the issue and in my setup disabling icsharpcode.ilspy-vscode fixes the issues with rust-analyzer.

Heh, another thing. Some logging in rust-analyzer might benefit from buffering. It’s emitting tiiiny syscall writes right now: image

Thanks @bjorn3 for the quick response.

Can you try /home/arong/Downloads/rust-analyzer-x86_64-unknown-linux-gnu analysis-stats . inside the project directory?

 ~/p/g/tests (master)> /home/arong/Downloads/rust-analyzer-x86_64-unknown-linux-gnu analysis-stats .
Failed to create perf counter: Operation not permitted (os error 1)
Database loaded:     440.13ms
Failed to create perf counter: Operation not permitted (os error 1)
  crates: 1, mods: 1, decls: 1, fns: 1
Item Collection:     1.40s
Failed to create perf counter: Operation not permitted (os error 1)
  exprs: 10, ??ty: 0 (0%), ?ty: 0 (0%), !ty: 0
Inference:           642.31ms
Total:               2.04s

No hang.

Are there any cargo or rustc processes running? Which rust-analyzer processes are running? (preferably with full commandline: ps ax | grep rust-analyzer)

 ~/p/g/tests (master)> ps ax | grep rust-analyzer
 290421 ?        Sl     0:00 /home/arong/Downloads/rust-analyzer-x86_64-unknown-linux-gnu-1
 290537 ?        S      0:00 /home/arong/Downloads/rust-analyzer-x86_64-unknown-linux-gnu-1 proc-macro
 290623 pts/0    S+     0:00 grep --color=auto rust-analyzer

Nothing unusual there, I think. I tried killing those processes and restarting vscode, and I get the same 2 processes.