rust-analyzer: Stuck at 'rust_analyzer: -32801: waiting for cargo metadata or cargo check'
I’m opening a project directory and rust-analyzer seems to be stuck at loading. I checked if perhaps was a project issue but the error persists in both big (5+ dependencies) and small projects (using 1 dependency). I’m using neovim v0.7.0-dev in Ubuntu. Any suggestion of how to solve this issue? Thanks in advance.
rust-analyzer version: (eg. output of “Rust Analyzer: Show RA Version” command) rust-analyzer d9b2291f5 2021-11-29 stable
rustc version: (eg. output of rustc -V)
rustc 1.56.1 (59eed8a2a 2021-11-01)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 17
- Comments: 44 (11 by maintainers)
Commits related to this issue
- Don't respond to LSP requests before startup. A common error found while using emacs + lsp-mode + rust-analyzer is that on startup I receive the following logs: ``` LSP :: Error from the Language Ser... — committed to rbartlensky/rust-analyzer by rbartlensky 2 years ago
- Don't respond to LSP requests before startup. A common error found while using emacs + lsp-mode + rust-analyzer is that on startup I receive the following logs: ``` LSP :: Error from the Language Ser... — committed to rbartlensky/rust-analyzer by rbartlensky 2 years ago
- Auto merge of #13985 - Veykril:content-modified, r=Veykril Don't respond with a ContentModified while loading the workspace Initially this was done to prevent frequent inlay hint flickering, but thi... — committed to rust-lang/rust-analyzer by bors a year ago
Having this issue as well, on Emacs with
lsp-modeandrustic.Not sure if this is the same error:
I think Rust-Analyzer takes some time to load. After that, it seems to be working normally. Though the red status line is quite annoying from time to time.
My setup: neovim + nvim-lsp + rust-analyzer on MacOS.
Having the same problem.
Same error happened in:
Got messages:
vim-lsp Log
Note: a lot of duplicate requests have been omitted here
It seems as though this error is caused by the client making requests shortly after startup, before
cargo metadataand/orcargo checkhave completed. If these commands must complete in order for the server to handle any requests, should rust-analyzer perhaps withold its response to the client’sinitializedrequest until these commands have completed? At the moment, theinitializedresponse is sent here while the commands are both dispatched here.Switching to pre-release version worked for me
I get the same error when i open project with nvim, this is my configuration. Looks like
rust-analyzerproblem.Uuh, running that command shouldn’t fix the problem for you 😅 I was more interested in seeing whether running cargo check manually would also fail for you or not. This seems rather odd since all that r-a usually does is running cargo metadata and cargo check.
Does running
cargo check --workspace --message-format=json --manifest-path {path to your projects cargo toml} --all-targetsmanually in your project work fine?Though I guess it gets stuck at calling cargo metadata
@hydra let’s continue in #14146.
I get this in eclipse corrosion on a ‘hello-world’ rust example, attached.
Screenshot:
Eclipse workspace: eclipse-workspace-4.24-rust-analyzer-10910.zip
Project: hello-world.zip
However, when i tried to get the version of the rust-analyzer to submit this comment I found that when i used the ‘Download rust analyzer’ button on the ‘Eclipse / Preferences / Rust’ window it downloaded
rust-analyzer-x86_64-pc-windows-msvc.gz, toD:\Users\Hydra\.local\binand extracted it in place so that I have:D:\Users\Hydra\.local\bin\rust-analyzer, but if you try and run that from a command prompt you get this:Which is correct, because
cmd.exeonly runs commands that end in certain extensions, e.g..exe. So I did this:ren .local\bin\rust-analyzer rust-analyzer.exeThen I restarted Eclipse and it immediately complained about my rust config being incorrect, which because it was pointing at
rust-analyzernotrust-analyzer.exe.So I changed it, as below:
And now the
waiting for cargois gone and the outline view works correctly, as below:My issue is likely a bug in Eclipse Corrosion, as it should download and extract files that have the correct file extensions for the operating system being used. I’ll try and find an issue on an appropriate repository and link to this comment.
EDIT: actually there is probably also a rust-analyzer distribution/artifacts/packaging issue, but I’m not sure who was responsible for creating the file that eclipse corrosion downloaded. Does anyone know if
rust-analyzer-x86_64-pc-windows-msvc.gzis supposed to containrust-analyzer.exeorrust-analyzer? The latter is certainly an issue, as demonstrated above, for windows users.Hope this helps someone, if it did, please ‘like/thumbs-up’ this comment so I know I’m not wasting my time writing up this solution.
Same problem.
Finally: I switch to the pre-release version and restart the VS Code. The problem seems disappear.
@khjcph @tranvnhan hey it’s the same error I’m facing still! There’s a few projects where even
rust-analyzeris not able to properly load unless I runcargo check --workspace --message-format=json --manifest-path {path to your projects cargo toml} --all-targetsbefore. It’s quite annoying. Did you guys found any workaround or have some insight of what might be causing this misbehavior?