Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stuck at 'rust_analyzer: -32801: waiting for cargo metadata or cargo check' #10910

Closed
luisvgs opened this issue Dec 3, 2021 · 44 comments · Fixed by #13985
Closed

Stuck at 'rust_analyzer: -32801: waiting for cargo metadata or cargo check' #10910

luisvgs opened this issue Dec 3, 2021 · 44 comments · Fixed by #13985
Labels
C-support Category: support questions S-unactionable Issue requires feedback, design decisions or is blocked on other work

Comments

@luisvgs
Copy link

luisvgs commented Dec 3, 2021

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 d9b2291 2021-11-29 stable

rustc version: (eg. output of rustc -V)
rustc 1.56.1 (59eed8a2a 2021-11-01)

@Veykril
Copy link
Member

Veykril commented Dec 3, 2021

Does running cargo check --workspace --message-format=json --manifest-path {path to your projects cargo toml} --all-targets manually in your project work fine?

Though I guess it gets stuck at calling cargo metadata

@luisvgs
Copy link
Author

luisvgs commented Dec 4, 2021

@Veykril hey that worked! The error still appears when opening a project file but it disappears after a few seconds. Do I need to run that command in every project now? How can I prevent this or why is this happening in first place? Thanks in advance for the help.

@Veykril
Copy link
Member

Veykril commented Dec 4, 2021

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.

@luisvgs
Copy link
Author

luisvgs commented Dec 4, 2021

@Veykril you are right, I'm still getting the same message in my other projects. I'm running out of ideas.

@lnicola
Copy link
Member

lnicola commented Dec 6, 2021

When you ran cargo check, did it take a long time?

@Veykril Veykril added the S-unactionable Issue requires feedback, design decisions or is blocked on other work label Dec 20, 2021
@tranvnhan
Copy link

tranvnhan commented Jan 4, 2022

Not sure if this is the same error:
image

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.

@khjcph
Copy link

khjcph commented Jan 4, 2022

Same setup and same issue as @tranvnhan :) Seems to be kindof working though.

@luisvgs
Copy link
Author

luisvgs commented Jan 11, 2022

@khjcph @tranvnhan hey it's the same error I'm facing still! There's a few projects where even rust-analyzer is not able to properly load unless I run cargo check --workspace --message-format=json --manifest-path {path to your projects cargo toml} --all-targets before. It's quite annoying. Did you guys found any workaround or have some insight of what might be causing this misbehavior?

@tranvnhan
Copy link

@khjcph @tranvnhan hey it's the same error I'm facing still! There's a few projects where even rust-analyzer is not able to properly load unless I run cargo check --workspace --message-format=json --manifest-path {path to your projects cargo toml} --all-targets before. It's quite annoying. Did you guys found any workaround or have some insight of what might be causing this misbehavior?

I have to learn to live with it 😅. No clue what happens.

@lnicola
Copy link
Member

lnicola commented Jan 11, 2022

Can anyone share some code where this happens?

@c02y
Copy link

c02y commented Jan 22, 2022

I got the same error when I open a Rust project whether I use either Nvim or Emacs

But rust-analyzer is working fine in both of them, function like go-to-definition and auto-completion works fine. It just shows the error in the beginning.

@Veykril
Copy link
Member

Veykril commented Jan 22, 2022

Is the project open source by any chance? A repro for this is needed to make this actionable.

@champly
Copy link

champly commented Feb 24, 2022

I get the same error when i open project with nvim, this is my configuration. Looks like rust-analyzer problem.

@luisvgs
Copy link
Author

luisvgs commented Feb 24, 2022

@champly the workaround that @Veykril provides partially works. I'm still dealing with the error as well when opening some of my projects, it fades away after a few seconds. AFAIK it has something to do with recent neovim versions, the built-in LSP breaks rust-analyzer. Somehow, if you try rust-tools the error disappears.

@Mingun
Copy link

Mingun commented Mar 18, 2022

It seems that rust-analyzer could not work if cargo check --workspace --message-format=json --manifest-path {path to your projects cargo toml} --all-targets failed, for example because crate uses #![feature()] gate that is allowed only on nightly compiler and you default compiler from the stable channel.

Also, in VS Code it seems failed if your workspace contains serde source tree -- in that case the following error is logged in the Rust Analyzer Language Server output panel:

[ERROR project_model::workspace] cyclic deps: serde_derive(CrateId(34)) -> serde(CrateId(31)), alternative path: serde(CrateId(31)) -> serde_derive(CrateId(34))
[ERROR rust_analyzer::reload] failed to switch build data: rust-analyzer failed to run build scripts:
error: could not compile `proc-macro2` due to 2 previous errors
error: build failed


[ERROR project_model::workspace] cyclic deps: serde_derive(CrateId(34)) -> serde(CrateId(31)), alternative path: serde(CrateId(31)) -> serde_derive(CrateId(34))

Deleting serde from my workspace and relaunching VS Code solves that problem.


After that it failing on compiling the log crate that come from dependencies of some crates in the workplace (in my case egui and/or eframe_template):

Rust Analyzer Language Server output panel:

[ERROR rust_analyzer::reload] failed to switch build data: rust-analyzer failed to run build scripts:
error: could not compile `log` due to 2 previous errors
error: build failed


[ERROR rust_analyzer::reload] failed to switch build data: rust-analyzer failed to run build scripts:
error: could not compile `log` due to 2 previous errors
error: build failed


[ERROR rust_analyzer::reload] failed to switch build data: rust-analyzer failed to run build scripts:
error: could not compile `log` due to 2 previous errors
error: build failed

Deleting egui and eframe_template from my workplace and relaunch VS Code solves that problem.


After that Rust Analyzer Language Server output panel even doesn't show in the VS Code and all seems right... but still not working.

Rust Analyzer Language Server Trace output panel is always empty (what the difference from Rust Analyzer Language Server?)

Rust Analyzer Client contains following output:

Rust Analyzer Client ``` INFO [18.03.2022, 20:36:53]: Extension version: 0.2.975 INFO [18.03.2022, 20:36:53]: Using configuration { cargoRunner: null, runnableEnv: null, inlayHints: { enable: true, renderColons: true, chainingHints: true, maxLength: 25, parameterHints: true, typeHints: true, hideNamedConstructorHints: false }, server: { path: null, extraEnv: null }, trace: { server: 'off', extension: false }, debug: { engine: 'auto', sourceFileMap: { '/rustc/': '${env:USERPROFILE}/.rustup/toolchains//lib/rustlib/src/rust' }, openDebugPane: false, engineSettings: {} }, assist: { exprFillDefault: 'todo', importGranularity: 'crate', importEnforceGranularity: false, importPrefix: 'plain', importGroup: true, allowMergingIntoGlobImports: true }, cache: { warmup: true }, callInfo: { full: true }, cargo: { autoreload: true, allFeatures: false, unsetTest: [ 'core' ], features: [], runBuildScripts: true, useRustcWrapperForBuildScripts: true, noDefaultFeatures: false, target: null, noSysroot: false }, checkOnSave: { enable: true, allFeatures: null, allTargets: true, command: 'check', noDefaultFeatures: null, target: null, extraArgs: [], features: null, overrideCommand: null }, completion: { addCallArgumentSnippets: true, addCallParenthesis: true, snippets: { 'Arc::new': { postfix: 'arc', body: 'Arc::new(${receiver})', requires: 'std::sync::Arc', description: 'Put the expression into an `Arc`', scope: 'expr' }, 'Rc::new': { postfix: 'rc', body: 'Rc::new(${receiver})', requires: 'std::rc::Rc', description: 'Put the expression into an `Rc`', scope: 'expr' }, 'Box::pin': { postfix: 'pinbox', body: 'Box::pin(${receiver})', requires: 'std::boxed::Box', description: 'Put the expression into a pinned `Box`', scope: 'expr' }, Ok: { postfix: 'ok', body: 'Ok(${receiver})', description: 'Wrap the expression in a `Result::Ok`', scope: 'expr' }, Err: { postfix: 'err', body: 'Err(${receiver})', description: 'Wrap the expression in a `Result::Err`', scope: 'expr' }, Some: { postfix: 'some', body: 'Some(${receiver})', description: 'Wrap the expression in an `Option::Some`', scope: 'expr' } }, postfix: { enable: true }, autoimport: { enable: true }, autoself: { enable: true }, privateEditable: { enable: false } }, diagnostics: { enable: true, enableExperimental: true, disabled: [], remapPrefix: {}, warningsAsHint: [], warningsAsInfo: [] }, experimental: { procAttrMacros: true }, files: { watcher: 'client', excludeDirs: [] }, highlightRelated: { references: true, exitPoints: true, breakPoints: true, yieldPoints: true }, highlighting: { strings: true }, hover: { documentation: true, linksInHover: true }, hoverActions: { debug: true, enable: true, gotoTypeDef: true, implementations: true, references: false, run: true }, joinLines: { joinElseIf: true, removeTrailingComma: true, unwrapTrivialBlock: true, joinAssignments: true }, lens: { debug: true, enable: true, implementations: true, run: true, methodReferences: false, references: false, enumVariantReferences: false, forceCustomCommands: true }, linkedProjects: [], lruCapacity: null, notifications: { cargoTomlNotFound: true }, primeCaches: { numThreads: 0 }, procMacro: { enable: true, server: null, ignored: {} }, runnables: { overrideCargo: null, cargoExtraArgs: [] }, rustcSource: null, rustfmt: { extraArgs: [], overrideCommand: null, enableRangeFormatting: false }, workspace: { symbol: { search: { scope: 'workspace', kind: 'only_types' } } } } INFO [18.03.2022, 20:36:53]: PersistentState: { serverVersion: '0.2.975' } INFO [18.03.2022, 20:36:54]: Using server binary at d:\Users\mingun\.vscode\extensions\matklad.rust-analyzer-0.2.975\server\rust-analyzer.exe INFO [18.03.2022, 20:36:54]: Extension version: 0.2.975 INFO [18.03.2022, 20:36:54]: Using configuration { cargoRunner: null, runnableEnv: null, inlayHints: { enable: true, renderColons: true, chainingHints: true, maxLength: 25, parameterHints: true, typeHints: true, hideNamedConstructorHints: false }, server: { path: null, extraEnv: null }, trace: { server: 'off', extension: false }, debug: { engine: 'auto', sourceFileMap: { '/rustc/': '${env:USERPROFILE}/.rustup/toolchains//lib/rustlib/src/rust' }, openDebugPane: false, engineSettings: {} }, assist: { exprFillDefault: 'todo', importGranularity: 'crate', importEnforceGranularity: false, importPrefix: 'plain', importGroup: true, allowMergingIntoGlobImports: true }, cache: { warmup: true }, callInfo: { full: true }, cargo: { autoreload: true, allFeatures: false, unsetTest: [ 'core' ], features: [], runBuildScripts: true, useRustcWrapperForBuildScripts: true, noDefaultFeatures: false, target: null, noSysroot: false }, checkOnSave: { enable: true, allFeatures: null, allTargets: true, command: 'check', noDefaultFeatures: null, target: null, extraArgs: [], features: null, overrideCommand: null }, completion: { addCallArgumentSnippets: true, addCallParenthesis: true, snippets: { 'Arc::new': { postfix: 'arc', body: 'Arc::new(${receiver})', requires: 'std::sync::Arc', description: 'Put the expression into an `Arc`', scope: 'expr' }, 'Rc::new': { postfix: 'rc', body: 'Rc::new(${receiver})', requires: 'std::rc::Rc', description: 'Put the expression into an `Rc`', scope: 'expr' }, 'Box::pin': { postfix: 'pinbox', body: 'Box::pin(${receiver})', requires: 'std::boxed::Box', description: 'Put the expression into a pinned `Box`', scope: 'expr' }, Ok: { postfix: 'ok', body: 'Ok(${receiver})', description: 'Wrap the expression in a `Result::Ok`', scope: 'expr' }, Err: { postfix: 'err', body: 'Err(${receiver})', description: 'Wrap the expression in a `Result::Err`', scope: 'expr' }, Some: { postfix: 'some', body: 'Some(${receiver})', description: 'Wrap the expression in an `Option::Some`', scope: 'expr' } }, postfix: { enable: true }, autoimport: { enable: true }, autoself: { enable: true }, privateEditable: { enable: false } }, diagnostics: { enable: true, enableExperimental: true, disabled: [], remapPrefix: {}, warningsAsHint: [], warningsAsInfo: [] }, experimental: { procAttrMacros: true }, files: { watcher: 'client', excludeDirs: [] }, highlightRelated: { references: true, exitPoints: true, breakPoints: true, yieldPoints: true }, highlighting: { strings: true }, hover: { documentation: true, linksInHover: true }, hoverActions: { debug: true, enable: true, gotoTypeDef: true, implementations: true, references: false, run: true }, joinLines: { joinElseIf: true, removeTrailingComma: true, unwrapTrivialBlock: true, joinAssignments: true }, lens: { debug: true, enable: true, implementations: true, run: true, methodReferences: false, references: false, enumVariantReferences: false, forceCustomCommands: true }, linkedProjects: [], lruCapacity: null, notifications: { cargoTomlNotFound: true }, primeCaches: { numThreads: 0 }, procMacro: { enable: true, server: null, ignored: {} }, runnables: { overrideCargo: null, cargoExtraArgs: [] }, rustcSource: null, rustfmt: { extraArgs: [], overrideCommand: null, enableRangeFormatting: false }, workspace: { symbol: { search: { scope: 'workspace', kind: 'only_types' } } } } INFO [18.03.2022, 20:36:55]: Extension version: 0.2.975 INFO [18.03.2022, 20:36:55]: Using configuration { cargoRunner: null, runnableEnv: null, inlayHints: { enable: true, renderColons: true, chainingHints: true, maxLength: 25, parameterHints: true, typeHints: true, hideNamedConstructorHints: false }, server: { path: null, extraEnv: null }, trace: { server: 'off', extension: false }, debug: { engine: 'auto', sourceFileMap: { '/rustc/': '${env:USERPROFILE}/.rustup/toolchains//lib/rustlib/src/rust' }, openDebugPane: false, engineSettings: {} }, assist: { exprFillDefault: 'todo', importGranularity: 'crate', importEnforceGranularity: false, importPrefix: 'plain', importGroup: true, allowMergingIntoGlobImports: true }, cache: { warmup: true }, callInfo: { full: true }, cargo: { autoreload: true, allFeatures: false, unsetTest: [ 'core' ], features: [], runBuildScripts: true, useRustcWrapperForBuildScripts: true, noDefaultFeatures: false, target: null, noSysroot: false }, checkOnSave: { enable: true, allFeatures: null, allTargets: true, command: 'check', noDefaultFeatures: null, target: null, extraArgs: [], features: null, overrideCommand: null }, completion: { addCallArgumentSnippets: true, addCallParenthesis: true, snippets: { 'Arc::new': { postfix: 'arc', body: 'Arc::new(${receiver})', requires: 'std::sync::Arc', description: 'Put the expression into an `Arc`', scope: 'expr' }, 'Rc::new': { postfix: 'rc', body: 'Rc::new(${receiver})', requires: 'std::rc::Rc', description: 'Put the expression into an `Rc`', scope: 'expr' }, 'Box::pin': { postfix: 'pinbox', body: 'Box::pin(${receiver})', requires: 'std::boxed::Box', description: 'Put the expression into a pinned `Box`', scope: 'expr' }, Ok: { postfix: 'ok', body: 'Ok(${receiver})', description: 'Wrap the expression in a `Result::Ok`', scope: 'expr' }, Err: { postfix: 'err', body: 'Err(${receiver})', description: 'Wrap the expression in a `Result::Err`', scope: 'expr' }, Some: { postfix: 'some', body: 'Some(${receiver})', description: 'Wrap the expression in an `Option::Some`', scope: 'expr' } }, postfix: { enable: true }, autoimport: { enable: true }, autoself: { enable: true }, privateEditable: { enable: false } }, diagnostics: { enable: true, enableExperimental: true, disabled: [], remapPrefix: {}, warningsAsHint: [], warningsAsInfo: [] }, experimental: { procAttrMacros: true }, files: { watcher: 'client', excludeDirs: [] }, highlightRelated: { references: true, exitPoints: true, breakPoints: true, yieldPoints: true }, highlighting: { strings: true }, hover: { documentation: true, linksInHover: true }, hoverActions: { debug: true, enable: true, gotoTypeDef: true, implementations: true, references: false, run: true }, joinLines: { joinElseIf: true, removeTrailingComma: true, unwrapTrivialBlock: true, joinAssignments: true }, lens: { debug: true, enable: true, implementations: true, run: true, methodReferences: false, references: false, enumVariantReferences: false, forceCustomCommands: true }, linkedProjects: [], lruCapacity: null, notifications: { cargoTomlNotFound: true }, primeCaches: { numThreads: 0 }, procMacro: { enable: true, server: null, ignored: {} }, runnables: { overrideCargo: null, cargoExtraArgs: [] }, rustcSource: null, rustfmt: { extraArgs: [], overrideCommand: null, enableRangeFormatting: false }, workspace: { symbol: { search: { scope: 'workspace', kind: 'only_types' } } } } ```
How it looks:

VS Code

@ghost
Copy link

ghost commented Mar 30, 2022

raerr

Having the same problem.

@flodiebold flodiebold added the C-support Category: support questions label Mar 31, 2022
@frankplow
Copy link

vim-lsp Log

Note: a lot of duplicate requests have been omitted here

Sun 10 Apr 2022 14:22:40 BST:["lsp#register_server","server registered","rust-analyzer"]
Sun 10 Apr 2022 14:22:40 BST:["s:on_text_document_did_open()",1,"rust","/home/frank/fun/euler/035_circular_primes","file:///home/frank/fun/euler/035_circular_primes/src/main.rs"]

Sun 10 Apr 2022 14:22:40 BST:["Starting server","rust-analyzer",["rust-analyzer"]]
Sun 10 Apr 2022 14:22:40 BST:[{"response":{"data":{"__data__":"vim-lsp","lsp_id":1,"server_name":"rust-analyzer"},"message":"started lsp server successfully"}}]
Sun 10 Apr 2022 14:22:40 BST:[{"response":{"error":{"data":{"lsp_id":1,"__error__":"vim-lsp","server_name":"rust-analyzer"},"code":0,"message":"ignore initialization lsp server due to empty root_uri"}}}]
Sun 10 Apr 2022 14:22:40 BST:["--->",1,"rust-analyzer",{"method":"initialize",...
Sun 10 Apr 2022 14:22:40 BST:["<---",1,"rust-analyzer",{"response":{...,"request":{"id":1,"jsonrpc":"2.0","method":"initialize",...
Sun 10 Apr 2022 14:22:40 BST:["--->",1,"rust-analyzer",{"method":"initialized","params":{}}]
Sun 10 Apr 2022 14:22:40 BST:["--->",1,"rust-analyzer",{"method":"textDocument/didOpen",...
Sun 10 Apr 2022 14:22:40 BST:["--->",1,"rust-analyzer",{"method":"textDocument/foldingRange","on_notification":"---funcref---","bufnr":1,"params":{"textDocument":{"uri":"file:///home/frank/fun/euler/035_circular_primes/src/main.rs"}},"sync":0}]
Sun 10 Apr 2022 14:22:40 BST:["<---",1,"rust-analyzer",{"response":{"id":2,"jsonrpc":"2.0","error":{"code":-32801,"message":"waiting for cargo metadata or cargo check"}},"request":{"id":2,"jsonrpc":"2.0","method":"textDocument/foldingRange","params":{"textDocument":{"uri":"file:///home/frank/fun/euler/035_circular_primes/src/main.rs"}}}}]
Sun 10 Apr 2022 14:22:41 BST:["--->",1,"rust-analyzer",{"method":"textDocument/documentHighlight","on_notification":"---funcref---","params":{"textDocument":{"uri":"file:///home/frank/fun/euler/035_circular_primes/src/main.rs"},"position":{"character":0,"line":0}}}]
Sun 10 Apr 2022 14:22:41 BST:["<---",1,"rust-analyzer",{"response":{"id":4,"jsonrpc":"2.0","error":{"code":-32801,"message":"waiting for cargo metadata or cargo check"}},"request":{"id":4,"jsonrpc":"2.0","method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///home/frank/fun/euler/035_circular_primes/src/main.rs"},"position":{"character":0,"line":0}}}}]
Sun 10 Apr 2022 14:22:41 BST:["--->",1,"rust-analyzer",{"method":"textDocument/codeAction","on_notification":"---funcref---","params":{"context":{"diagnostics":[],"only":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite"]},"range":{"end":{"character":57,"line":0},"start":{"character":0,"line":0}},"textDocument":{"uri":"file:///home/frank/fun/euler/035_circular_primes/src/main.rs"}}}]
Sun 10 Apr 2022 14:22:41 BST:["<---",1,"rust-analyzer",{"response":{"id":5,"jsonrpc":"2.0","error":{"code":-32801,"message":"waiting for cargo metadata or cargo check"}},"request":{"id":5,"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"context":{"diagnostics":[],"only":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite"]},"range":{"end":{"character":57,"line":0},"start":{"character":0,"line":0}},"textDocument":{"uri":"file:///home/frank/fun/euler/035_circular_primes/src/main.rs"}}}}]
⋮
Sun 10 A
Sun 10 Apr 2022 14:22:45 BST:["--->",1,"rust-analyzer",{"method":"textDocument/codeAction","on_notification":"---funcref---","params":{"context":{"diagnostics":[],"only":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite"]},"range":{"end":{"character":1,"line":57},"start":{"character":0,"line":57}},"textDocument":{"uri":"file:///home/frank/fun/euler/035_circular_primes/src/main.rs"}}}]
Sun 10 Apr 2022 14:22:47 BST:["<---",1,"rust-analyzer",{"response":{"id":6,"jsonrpc":"2.0","result":null},"request":{"id":6,"jsonrpc":"2.0","method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///home/frank/fun/euler/035_circular_primes/src/main.rs"},"position":{"character":0,"line":57}}}}]
Sun 10 Apr 2022 14:22:49 BST:["s:on_text_document_did_close()",1]

It seems as though this error is caused by the client making requests shortly after startup, before cargo metadata and/or cargo check have 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's initialized request until these commands have completed? At the moment, the initialized response is sent here while the commands are both dispatched here.

@percy507
Copy link

Same problem.

Finally: I switch to the pre-release version and restart the VS Code. The problem seems disappear.

image

@rib
Copy link

rib commented May 13, 2022

I'm seeing this issue in VSCode with the egui project here: https://github.com/emilk/egui

As a hack I have needed to create a .vscode/settings.json like:

{
    "rust-analyzer.cargo.target": "disabled"
}

because there doesn't seem to a way to disable rust-analyzer for a single project? If I don't disable it then I can't build egui manually while rust-analyzer is perpetually holding the build lock (and I really don't want to disable rust-analyzer entirely because it's working fine for other projects).

Enabling verbose tracing I don't really see any obvious clue about what's going wrong.

It seems to behave the same if I open the top-level egui/ workspace or egui/egui-wgpu/ which is where I've been trying to make changes.

Manually running cargo check --workspace --message-format=json --manifest-path {path to your projects cargo toml} --all-targets as suggested earlier in this issue seems to work fine for me.

Versions:
rust-analyzer version: 94fa8a653 2022-05-12 nightly
(I don't currently see any alternative versions available within VSCode)
rustc 1.60.0 (7737e0b5c 2022-04-04)
OS: Windows 10

Visual Studio Code About:

Version: 1.67.1 (system setup)
Commit: da15b6fd3ef856477bf6f4fb29ba1b7af717770d
Date: 2022-05-06T12:37:03.389Z
Electron: 17.4.1
Chromium: 98.0.4758.141
Node.js: 16.13.0
V8: 9.8.177.13-electron.0
OS: Windows_NT x64 10.0.19044

@rib
Copy link

rib commented May 14, 2022

Okey, so poking a bit further (I figured I'd try just hacking away big chunks of the egui repo that I wasn't working on to see if I could get rust-analyzer working) I found that they have a rust-toolchain file at the top of the project that contains:

[toolchain]
channel = "1.60.0"
components = [ "rustfmt", "clippy" ]
targets = [ "wasm32-unknown-unknown" ]

and if I restore everything I tried deleting in the repo and just delete that file it seems to workaround this issue for me.

rbartlensky added a commit to rbartlensky/rust-analyzer that referenced this issue May 14, 2022
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 Server: waiting for cargo metadata or
cargo check (Unknown error) [4 times]
```

This looks similar to rust-lang#10910, and as some people mention, everything
works well once `cargo metadata` finishes running.

I stubmled accross a [helpful comment] which made me think that it
might be worth waiting for startup to finish, before attempting to
respond to LSP requests.

[helpful comment](https://github.com/rust-lang/rust-analyzer/blob/d382e24a11c8706b201c8437894506d191691334/crates/rust-analyzer/src/main_loop.rs#L567-L568)
rbartlensky added a commit to rbartlensky/rust-analyzer that referenced this issue May 14, 2022
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 Server: waiting for cargo metadata or
cargo check (Unknown error) [4 times]
```

This looks similar to rust-lang#10910, and as some people mention, everything
works well once `cargo metadata` finishes running.

I stumbled accross a [helpful
comment](https://github.com/rust-lang/rust-analyzer/blob/d382e24a11c8706b201c8437894506d191691334/crates/rust-analyzer/src/main_loop.rs#L567-L568)
which made me think that it might be worth waiting for startup to
finish, before attempting to respond to LSP requests.
@Visne
Copy link

Visne commented Jul 7, 2022

Having this issue as well, on Emacs with lsp-mode and rustic.

@udsamani
Copy link

I ran into the same issue. However, was able to solve that by updating rust to 1.63.

@hydra
Copy link

hydra commented Aug 24, 2022

I get this in eclipse corrosion on a 'hello-world' rust example, attached.

Screenshot:
image

Eclipse workspace:
eclipse-workspace-4.24-rust-analyzer-10910.zip

Project:
hello-world.zip

  C/C++ Autotools support	10.7.1.202208160035	org.eclipse.cdt.autotools.feature.group	Eclipse CDT
  C/C++ CMake Build Support - Preview	10.7.1.202208160035	org.eclipse.cdt.cmake.feature.group	Eclipse CDT
  C/C++ Debug Adapter GDB Debugger Integration	10.7.1.202208160035	org.eclipse.cdt.debug.dap.feature.group	Eclipse CDT
  C/C++ Debug Adapter GDB Hardware Debugger Integration	10.7.1.202208160035	org.eclipse.cdt.debug.dap.gdbjtag.feature.group	Eclipse CDT
  C/C++ Development Tools	10.7.1.202208222120	org.eclipse.cdt.feature.group	Eclipse CDT
  C/C++ Docker Container Launch Support	10.7.1.202208160035	org.eclipse.cdt.docker.launcher.feature.group	Eclipse CDT
  C/C++ GCC Cross Compiler Support	10.7.1.202208160035	org.eclipse.cdt.build.crossgcc.feature.group	Eclipse CDT
  C/C++ GDB Hardware Debugging	10.7.1.202208160035	org.eclipse.cdt.debug.gdbjtag.feature.group	Eclipse CDT
  C/C++ Launch over Serial	10.7.1.202208160035	org.eclipse.cdt.launch.serial.feature.feature.group	Eclipse CDT
  C/C++ Library API Documentation Hover Help	8.7.0.202206072042	org.eclipse.linuxtools.cdt.libhover.feature.feature.group	Eclipse Linux Tools
  C/C++ Memory View Enhancements	10.7.1.202208160035	org.eclipse.cdt.debug.ui.memory.feature.group	Eclipse CDT
  C/C++ Meson Build Support - Preview	10.7.1.202208160035	org.eclipse.cdt.meson.feature.group	Eclipse CDT
  C/C++ Remote Launch	10.7.1.202208160035	org.eclipse.cdt.launch.remote.feature.group	Eclipse CDT
  C/C++ Standalone Debugger	10.7.1.202208160035	org.eclipse.cdt.debug.standalone.feature.group	Eclipse CDT
  C/C++ Test runner client for UnitTest View	10.7.1.202208160035	org.eclipse.cdt.unittest.feature.feature.group	Eclipse CDT
  C/C++ Unit Testing Support	10.7.1.202208160035	org.eclipse.cdt.testsrunner.feature.feature.group	Eclipse CDT
  ChangeLog Management Tools for C/C++	8.7.0.202206072042	org.eclipse.linuxtools.changelog.c.feature.group	Eclipse Linux Tools
  Corrosion: Rust edition in Eclipse IDE	1.2.4.202206282034	org.eclipse.corrosion.feature.feature.group	Eclipse Corrosion
  Eclipse IDE for Embedded C/C++ Developers	4.24.0.20220609-1200	epp.package.embedcpp	Eclipse Packaging Project
  Eclipse Java Development Tools	3.18.1200.v20220607-0700	org.eclipse.jdt.feature.group	Eclipse.org
  Eclipse Java EE Developer Tools	3.26.0.v202204042240	org.eclipse.jst.enterprise_ui.feature.feature.group	Eclipse Web Tools Platform
  Eclipse Web Developer Tools	3.26.0.v202204091445	org.eclipse.wst.web_ui.feature.feature.group	Eclipse Web Tools Platform
  Eclipse XML Editors and Tools	3.26.0.v202204091445	org.eclipse.wst.xml_ui.feature.feature.group	Eclipse Web Tools Platform
  Embedded C/C++ ADuCM360 Project Template	6.3.0.202208180721	org.eclipse.embedcdt.templates.ad.feature.group	Eclipse Embedded CDT
  Embedded C/C++ Arm Cross Compiler	6.3.0.202208180721	org.eclipse.embedcdt.managedbuild.cross.arm.feature.group	Eclipse Embedded CDT
  Embedded C/C++ CMSIS Packs (Experimental)	6.3.0.202208180721	org.eclipse.embedcdt.packs.feature.group	Eclipse Embedded CDT
  Embedded C/C++ CodeRed Debug Perspective	6.3.0.202208180721	org.eclipse.embedcdt.codered.feature.group	Eclipse Embedded CDT
  Embedded C/C++ Core	6.3.0.202208180721	org.eclipse.embedcdt.feature.group	Eclipse Embedded CDT
  Embedded C/C++ Documentation (Placeholder)	6.3.0.202208180721	org.eclipse.embedcdt.doc.user.feature.group	Eclipse Embedded CDT
  Embedded C/C++ Freescale Project Templates	6.3.0.202208180721	org.eclipse.embedcdt.templates.freescale.feature.group	Eclipse Embedded CDT
  Embedded C/C++ GDB JTAG Debugging	6.3.0.202208180721	org.eclipse.embedcdt.debug.gdbjtag.feature.group	Eclipse Embedded CDT
  Embedded C/C++ Generic Arm Cortex-M Project Template	6.3.0.202208180721	org.eclipse.embedcdt.templates.cortexm.feature.group	Eclipse Embedded CDT
  Embedded C/C++ J-Link Debugging	6.3.0.202208180721	org.eclipse.embedcdt.debug.gdbjtag.jlink.feature.group	Eclipse Embedded CDT
  Embedded C/C++ OpenOCD Debugging	6.3.0.202208180721	org.eclipse.embedcdt.debug.gdbjtag.openocd.feature.group	Eclipse Embedded CDT
  Embedded C/C++ PyOCD Debugging	6.3.0.202208180721	org.eclipse.embedcdt.debug.gdbjtag.pyocd.feature.group	Eclipse Embedded CDT
  Embedded C/C++ QEMU Debugging	6.3.0.202208180721	org.eclipse.embedcdt.debug.gdbjtag.qemu.feature.group	Eclipse Embedded CDT
  Embedded C/C++ RISC-V Cross Compiler	6.3.0.202208180721	org.eclipse.embedcdt.managedbuild.cross.riscv.feature.group	Eclipse Embedded CDT
  Embedded C/C++ SiFive RISC-V Project Template	6.3.0.202208180721	org.eclipse.embedcdt.templates.sifive.feature.group	Eclipse Embedded CDT
  Embedded C/C++ STM32Fx Project Templates	6.3.0.202208180721	org.eclipse.embedcdt.templates.stm.feature.group	Eclipse Embedded CDT
  GCov Integration	8.7.0.202206072042	org.eclipse.linuxtools.gcov.feature.group	Eclipse Linux Tools
  GDB Tracepoint Analysis	8.0.0.202206082347	org.eclipse.tracecompass.gdbtrace.feature.group	Eclipse Trace Compass
  Git integration for Eclipse	6.2.0.202206071550-r	org.eclipse.egit.feature.group	Eclipse EGit
  GProf Integration	8.7.0.202206072042	org.eclipse.linuxtools.gprof.feature.feature.group	Eclipse Linux Tools
  Java implementation of Git	6.2.0.202206071550-r	org.eclipse.jgit.feature.group	Eclipse JGit
  JavaScript Development Tools	2.4.200.v202204112136	org.eclipse.wst.jsdt.feature.feature.group	Eclipse Web Tools Platform
  JUnit Test runner client for UnitTest View	1.0.200.v20220204-2234	org.eclipse.jdt.ui.unittest.junit.feature.feature.group	Eclipse.org
  JustJ Adoptium OpenJDK Hotspot JRE Complete	18.0.1.v20220515-1614	org.eclipse.justj.openjdk.hotspot.jre.full.feature.group	Eclipse JustJ
  LaunchBar	10.7.1.202208160035	org.eclipse.launchbar.feature.group	Eclipse CDT
  Library Hover help for devhelp documentation	8.7.0.202206072042	org.eclipse.linuxtools.cdt.libhover.devhelp.feature.feature.group	Eclipse Linux Tools
  LTTng Kernel Analysis	8.0.0.202206082347	org.eclipse.tracecompass.lttng2.kernel.feature.group	Eclipse Trace Compass
  LTTng Tracer Control	8.0.0.202206082347	org.eclipse.tracecompass.lttng2.control.feature.group	Eclipse Trace Compass
  LTTng Userspace Analysis	8.0.0.202206082347	org.eclipse.tracecompass.lttng2.ust.feature.group	Eclipse Trace Compass
  Marketplace Client	1.10.0.v20220502-0731	org.eclipse.epp.mpc.feature.group	Eclipse Marketplace Client
  Mylyn WikiText	3.0.42.202201072301	org.eclipse.mylyn.wikitext_feature.feature.group	Eclipse Mylyn
  Oomph Setup	1.25.0.v20220607-1104	org.eclipse.oomph.setup.feature.group	Eclipse Oomph Project
  Remote Launch Targets	10.7.1.202208160035	org.eclipse.launchbar.remote.feature.group	Eclipse CDT
  RPM Tools	8.7.0.202206072042	org.eclipse.linuxtools.rpm.feature.group	Eclipse Linux Tools
  ShellWax	1.2.0.20220712-1356	org.eclipse.shellwax.feature.feature.group	null
  TM Terminal	10.7.1.202208160035	org.eclipse.tm.terminal.feature.feature.group	Eclipse CDT
  TM Terminal Serial Connector Extensions	10.7.1.202208160035	org.eclipse.tm.terminal.connector.cdtserial.feature.feature.group	Eclipse CDT
  Valgrind Tools Integration	8.7.0.202206072042	org.eclipse.linuxtools.valgrind.feature.group	Eclipse Linux Tools
rustc --version
rustc 1.64.0-nightly (1c7b36d4d 2022-07-12)

rustup --version
rustup 1.25.1 (bb60b1e89 2022-07-12)

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, to D:\Users\Hydra\.local\bin and 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:

image

Which is correct, because cmd.exe only runs commands that end in certain extensions, e.g. .exe. So I did this:

ren .local\bin\rust-analyzer rust-analyzer.exe

image

rust-analyzer 0.3.1148-standalone (2b472f668 2022-07-31)

Then I restarted Eclipse and it immediately complained about my rust config being incorrect, which because it was pointing at rust-analyzer not rust-analyzer.exe.

So I changed it, as below:

image

And now the waiting for cargo is gone and the outline view works correctly, as below:

image

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.gz is supposed to contain rust-analyzer.exe or rust-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.

@hydra
Copy link

hydra commented Aug 24, 2022

sigh seems like I spoke to soon:

It still hangs. seems like it's just getting stuck on something and then becomes unresponsive.

image

Same workspace, same files, no changes. Just restarted Eclipse.

IMHO, the packaging issue on windows still exists and I raised eclipse-corrosion/corrosion#410 to track any changes in Eclipse Corrosion that might be needed.

@hydra
Copy link

hydra commented Aug 24, 2022

After switching back to the IDE window a few minutes later I found this:

image

eclipse.buildId=4.24.0.I20220607-0700
java.version=18.0.1
java.vendor=Eclipse Adoptium
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_GB
Framework arguments:  -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -data D:\Users\Hydra\Documents\dev\eclipse\4.24-rustcontrol -product org.eclipse.epp.package.embedcpp.product

org.eclipse.jface.text
Error
Wed Aug 24 17:22:00 CEST 2022
org.eclipse.lsp4j.jsonrpc.ResponseErrorException: waiting for cargo metadata or cargo check

java.util.concurrent.CompletionException: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: waiting for cargo metadata or cargo check
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:332)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:347)
	at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:708)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
	at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2162)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
	at org.eclipse.lsp4e.LanguageServerWrapper.lambda$3(LanguageServerWrapper.java:270)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: waiting for cargo metadata or cargo check
	... 11 more

This error is logged every time you restart the IDE (for my 'hello-world' example above).

I also get this error:

eclipse.buildId=4.24.0.I20220607-0700
java.version=18.0.1
java.vendor=Eclipse Adoptium
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_GB
Framework arguments:  -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -product org.eclipse.epp.package.embedcpp.product -data file:/D:/Users/Hydra/Documents/dev/eclipse/4.24-rustcontrol/ -product org.eclipse.epp.package.embedcpp.product

org.eclipse.lsp4e
Error
Wed Aug 24 17:45:19 CEST 2022
org.eclipse.lsp4j.jsonrpc.ResponseErrorException: waiting for cargo metadata or cargo check

java.util.concurrent.ExecutionException: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: waiting for cargo metadata or cargo check
	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2096)
	at org.eclipse.lsp4e.LanguageServerWrapper.lambda$12(LanguageServerWrapper.java:456)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: waiting for cargo metadata or cargo check
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
	at org.eclipse.lsp4e.LanguageServerWrapper.lambda$3(LanguageServerWrapper.java:270)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

@flodiebold
Copy link
Member

I'm not sure the .exe thing is a problem -- it seems like rust-analyzer was already running before your change.

Does anyone know if rust-analyzer-x86_64-pc-windows-msvc.gz is supposed to contain rust-analyzer.exe or rust-analyzer ?

.gz files don't contain filenames. This is just a single compressed file, so what it's named after decompressing depends on whoever decompresses it.

The "waiting for cargo metadata or cargo check" is also not necessarily a problem, unless doesn't stop happening once rust-analyzer has settled down. Ideally the IDE would give you a way of retrying the request or do that automatically.

@hydra
Copy link

hydra commented Aug 24, 2022

I'm not sure the .exe thing is a problem -- it seems like rust-analyzer was already running before your change.

yes, but only from inside eclipse. it's uncommon and unhelpful on windows to have an PE executable without .exe extension.

.gz files don't contain filenames. This is just a single compressed file, so what it's named after decompressing depends on whoever decompresses it.

as yes, it's just a .gz, not a .tar.gz. In which case the code that decompresses it should add the .exe extension.

The "waiting for cargo metadata or cargo check" is also not necessarily a problem, unless doesn't stop happening once rust-analyzer has settled down. Ideally the IDE would give you a way of retrying the request or do that automatically.

It doesn't 'settle down' on some files at all, and it's a problem if it's not consistent too. Like sometimes the 'outline' view works, other times it does not. To the end-user it appears random.

@EmblemWu
Copy link

EmblemWu commented Sep 7, 2022

same error got on doom emacs+m1 Mac+LSPrustic

@h-mikisato
Copy link

Same error happened in:

  • Windows11 Home 21H2
  • GNU Emacs 28.1 (build 52, x86_64-w64-mingw32) of 2022-04-05
  • lsp-mode 20220918.1522
  • rust-analyzer 0.3.1212-standalone (187bee0 2022-09-19)
  • Rust 1.63.0

Got messages:

LSP :: Connected to [rust-analyzer:29100/starting].
LSP :: rust-analyzer:29100 initialized successfully in folders: (c:/path/to/project)
LSP :: Error from the Language Server: waiting for cargo metadata or cargo check (Unknown error) [3 times]

@ivansanchez-oss
Copy link

i have the same problem in ubuntu:

  • rustc 1.66.0-nightly (c0983a9aa 2022-10-12)
  • rust-analyzer 0.3.1131-standalone (897a7ec 2022-07-17)

but I realized that it is a problem related to the crates, I have a project with two crates, rust-analyzer gets stuck when I import the bincode library in one of my crates, I am trying to make a minimum reproducible example

@lnicola
Copy link
Member

lnicola commented Oct 26, 2022

@Ivan-Sanchez-Diaz I suspect it's just cargo updating the crate registry.

@ivansanchez-oss
Copy link

my bad, I made some changes in the network adapter that affected my WSL2 distribution, therefore it was offline, sorry for the noise!

@installgentoo
Copy link

Same error have been occurring in QtCreator since 8.0 https://bugreports.qt.io/browse/QTCREATORBUG-27856

@lnicola
Copy link
Member

lnicola commented Nov 7, 2022

@installgentoo the QtCreator report seems unrelated. Depending on whichever problem you're running into, consider running cargo check from the terminal to watch the registry being updated, or filing a new issue whatever panic Qt Creator is running into.

@installgentoo
Copy link

@installgentoo the QtCreator report seems unrelated. Depending on whichever problem you're running into, consider running cargo check from the terminal to watch the registry being updated, or filing a new issue whatever panic Qt Creator is running into.

in the latest log that i ran with debug i get

        "code": -32801,
        "message": "waiting for cargo metadata or cargo check"
    },

and then analyzer crashes. Notably everything works on 7, where QtCreator apparently communicated synchronously to the server(or ignored "Initialized" response, i'm not quite sure yet), creator displays a little "cargo check" progress popup. And everything indeed fetches and works.

@drowningliu
Copy link

It seems that rust-analyzer could not work if cargo check --workspace --message-format=json --manifest-path {path to your projects cargo toml} --all-targets failed, for example because crate uses #![feature()] gate that is allowed only on nightly compiler and you default compiler from the stable channel.

Also, in VS Code it seems failed if your workspace contains serde source tree -- in that case the following error is logged in the Rust Analyzer Language Server output panel:

[ERROR project_model::workspace] cyclic deps: serde_derive(CrateId(34)) -> serde(CrateId(31)), alternative path: serde(CrateId(31)) -> serde_derive(CrateId(34))
[ERROR rust_analyzer::reload] failed to switch build data: rust-analyzer failed to run build scripts:
error: could not compile `proc-macro2` due to 2 previous errors
error: build failed


[ERROR project_model::workspace] cyclic deps: serde_derive(CrateId(34)) -> serde(CrateId(31)), alternative path: serde(CrateId(31)) -> serde_derive(CrateId(34))

Deleting serde from my workspace and relaunching VS Code solves that problem.

After that it failing on compiling the log crate that come from dependencies of some crates in the workplace (in my case egui and/or eframe_template):

Rust Analyzer Language Server output panel:

[ERROR rust_analyzer::reload] failed to switch build data: rust-analyzer failed to run build scripts:
error: could not compile `log` due to 2 previous errors
error: build failed


[ERROR rust_analyzer::reload] failed to switch build data: rust-analyzer failed to run build scripts:
error: could not compile `log` due to 2 previous errors
error: build failed


[ERROR rust_analyzer::reload] failed to switch build data: rust-analyzer failed to run build scripts:
error: could not compile `log` due to 2 previous errors
error: build failed

Deleting egui and eframe_template from my workplace and relaunch VS Code solves that problem.

After that Rust Analyzer Language Server output panel even doesn't show in the VS Code and all seems right... but still not working.

Rust Analyzer Language Server Trace output panel is always empty (what the difference from Rust Analyzer Language Server?)

Rust Analyzer Client contains following output:

Rust Analyzer Client
How it looks:

it happened in my projs too. noticed that the 'serde' you mention, i just write 'log' or 'log4j' before 'serde' in cargo.toml 's dependcies, and it works
1668706105078

@worikgh
Copy link

worikgh commented Dec 27, 2022

I am seeing this error using rustic from this repository

I created a new project: cd /tmp; cargo new test_issue

I see:

LSP :: Connected to [rust-analyzer:11070/starting /tmp/test_issue].
LSP :: rust-analyzer found 1 invalid config value:
/inlayHints/reborrowHints/enable: data did not match any variant of untagged enum ReborrowHintsDef
LSP :: rust-analyzer:11070 initialized successfully in folders: (/tmp/test_issue)
LSP :: Error from the Language Server: waiting for cargo metadata or cargo check (Unknown error) [8 times]

in my *Messages* buffer

As for cargo check... I am unsure if this is a success or a fail, it is all opaque to me:

/tmp $ cargo check --workspace --message-format=json --manifest-path /tmp/test_issue/Cargo.toml --all-targets
{"reason":"compiler-artifact","package_id":"test_issue 0.1.0 (path+file:///tmp/test_issue)","manifest_path":"/tmp/test_issue/Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"test_issue","src_path":"/tmp/test_issue/src/main.rs","edition":"2021","doc":true,"doctest":false,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":true},"features":[],"filenames":["/tmp/test_issue/target/debug/deps/libtest_issue-30abfe3ff80c5c93.rmeta"],"executable":null,"fresh":true}
{"reason":"compiler-artifact","package_id":"test_issue 0.1.0 (path+file:///tmp/test_issue)","manifest_path":"/tmp/test_issue/Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"test_issue","src_path":"/tmp/test_issue/src/main.rs","edition":"2021","doc":true,"doctest":false,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["/tmp/test_issue/target/debug/deps/libtest_issue-c8f654c9f2b1a9e3.rmeta"],"executable":null,"fresh":true}
{"reason":"build-finished","success":true}
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s

@hydra
Copy link

hydra commented Feb 8, 2023

For me this isn't fixed in Eclipse with rust-analyzer 0.3.1394-standalone (0b32b65ca 2023-02-05) from https://github.com/rust-lang/rust-analyzer/releases/tag/2023-02-06 (downloaded rust-analyzer-x86_64-pc-windows-msvc.zip and extracted so that i have D:\Users\Hydra\.local\bin\rust-analyzer.exe and the IDE is configured to use that specific file. Old version /without/ the .exe extension that Eclipse downloads and extracts is deleted to be sure.

It's certainly better, but it still dies and in Eclipse 2/ Corrosion the end user experiance is that the IDE shows a 'Language Background Server Job' that never completes, task manager shows multiple instances of 'rust-analyzer.exe' and hover-over always fails with two errors in the IDE log:

image

image

image

Could not get hover region due to timeout after 500 miliseconds

java.util.concurrent.TimeoutException
	at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095)
	at org.eclipse.lsp4e.operations.hover.LSPTextHover.getHoverRegion(LSPTextHover.java:152)
...

and

Could not get hover information due to timeout after 500 miliseconds

java.util.concurrent.TimeoutException
	at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095)
	at org.eclipse.lsp4e.operations.hover.LSPTextHover.getHoverInfo(LSPTextHover.java:73)
...

Version details:

rust-analyzer 0.3.1394-standalone (0b32b65ca 2023-02-05)
Eclipse IDE for Embedded C/C++ Developers	4.26.0.20221201-1200	epp.package.embedcpp	Eclipse Packaging Project
Corrosion: Rust edition in Eclipse IDE	1.2.5.202209271915	org.eclipse.corrosion.feature.feature.group	Eclipse Corrosion

@lnicola
Copy link
Member

lnicola commented Feb 8, 2023

@hydra that sounds like an unrelated issue. But I don't understand, does Eclipse kill the server if it doesn't respond in 500 ms to a request?

@hydra
Copy link

hydra commented Feb 14, 2023

@hydra that sounds like an unrelated issue. But I don't understand, does Eclipse kill the server if it doesn't respond in 500 ms to a request?

Nope, it just gets stuck in task manager with zero-cpu usage, if you kill the task it spawns new ones, some of which complete depending on which files you have open. It doesn't seem to matter which files I have open though, it always does it sooner or later.

The root issue is likely not in Eclipse, but in rust analyzer, that said if there's a way to get logs of the communication between the two programs then I might be able to help get them so that someone taking charge of this issue can look at them to see if there's anything wrong. If this is possible then please can you either tell me how to get such logs (e.g. running a debug version of rust-analyzer and/or passing extra args to it) or point me at the docs on how I might go about this?

@lnicola
Copy link
Member

lnicola commented Feb 14, 2023

The root issue is likely not in Eclipse, but in rust analyzer

🍿

a way to get logs of the communication between the two programs

Yeah, see RA_LOG=info here. Eclipse might also have a log window, I don't know.

@lnicola
Copy link
Member

lnicola commented Feb 14, 2023

@hydra let's continue in #14146.

@PeteDevoy
Copy link

PeteDevoy commented Feb 20, 2024

Something to try for those people on VS Code coming off Google:

  1. Right click rust-analyzer in the status bar and chose Reload Workspace and then Restart Server.
  2. Close all open code tabs .
  3. Close VS Code.
  4. Reopen VS Code.

For me, these things were the last things I did before it started working. Not sure if all steps are necessary... I think step 2 perhaps the crucial one but I don't have time to try and reproduce right-now.

@sebastiantf
Copy link

Switching to pre-release version worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-support Category: support questions S-unactionable Issue requires feedback, design decisions or is blocked on other work
Projects
None yet
Development

Successfully merging a pull request may close this issue.