rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

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

Open luisvgs opened this issue 3 years ago • 29 comments

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)

luisvgs avatar Dec 03 '21 00:12 luisvgs

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

Veykril avatar Dec 03 '21 17:12 Veykril

@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.

luisvgs avatar Dec 04 '21 00:12 luisvgs

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.

Veykril avatar Dec 04 '21 00:12 Veykril

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

luisvgs avatar Dec 04 '21 01:12 luisvgs

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

lnicola avatar Dec 06 '21 07:12 lnicola

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.

tranvnhan avatar Jan 04 '22 19:01 tranvnhan

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

khjcph avatar Jan 04 '22 20:01 khjcph

@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?

luisvgs avatar Jan 11 '22 01:01 luisvgs

@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.

tranvnhan avatar Jan 11 '22 11:01 tranvnhan

Can anyone share some code where this happens?

lnicola avatar Jan 11 '22 19:01 lnicola

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.

c02y avatar Jan 22 '22 21:01 c02y

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

Veykril avatar Jan 22 '22 21:01 Veykril

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

champly avatar Feb 24 '22 00:02 champly

@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.

luisvgs avatar Feb 24 '22 19:02 luisvgs

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

Mingun avatar Mar 18 '22 15:03 Mingun

raerr

Having the same problem.

ghost avatar Mar 30 '22 16:03 ghost

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.

frankplow avatar Apr 10 '22 14:04 frankplow

Same problem.

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

image

percy507 avatar Apr 17 '22 08:04 percy507

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 avatar May 13 '22 23:05 rib

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.

rib avatar May 14 '22 00:05 rib

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

Visne avatar Jul 07 '22 15:07 Visne

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

udsamani avatar Aug 24 '22 14:08 udsamani

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 avatar Aug 24 '22 14:08 hydra

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 https://github.com/eclipse/corrosion/issues/410 to track any changes in Eclipse Corrosion that might be needed.

hydra avatar Aug 24 '22 15:08 hydra

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)

hydra avatar Aug 24 '22 15:08 hydra

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.

flodiebold avatar Aug 24 '22 17:08 flodiebold

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.

hydra avatar Aug 24 '22 20:08 hydra

same error got on doom emacs+m1 Mac+LSPrustic

EmblemWu avatar Sep 07 '22 00:09 EmblemWu

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 (187bee0bb 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]

h-mikisato avatar Sep 19 '22 12:09 h-mikisato

i have the same problem in ubuntu:

  • rustc 1.66.0-nightly (c0983a9aa 2022-10-12)
  • rust-analyzer 0.3.1131-standalone (897a7ec4b 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

ivansanchez-oss avatar Oct 26 '22 17:10 ivansanchez-oss