rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.25k stars 1.6k forks source link

"terminated with exit code 101" and "Failed to discover workspace" #14003

Open DimanNe opened 1 year ago

DimanNe commented 1 year ago

Forum for questions: https://users.rust-lang.org/c/ide/14

No one replies here --- https://users.rust-lang.org/t/error-rust-analyzer-failed-to-discover-workspace/87621/1

rust-analyzer version: rust-analyzer 1.66.1 (90743e7 2023-01-10) rustc version: rustc 1.66.1 (90743e729 2023-01-10)

I installed rust-analyzer via: rustup component add rust-analyzer. And told my IDE to use this: /home/dimanne/.cargo/bin/rustup run stable rust-analyzer -v --log-file /home/dimanne/ra.txt --no-log-buffering.

But it is not working for me...

Attempt 1: Empty initializationOptions

Here is full debug output: https://gist.github.com/DimanNe/66cbc6c0622e655ba94739ea6e4e10d9

Attempt 2: Set linkedProjects

I tried specifying linkedProjects in initializationOptions:

{
  "linkedProjects": ["/home/dimanne/devel/raspberrypi/thermo_rust/thermo/Cargo.toml"]
}

I got the following output:

LanguageClient Rust: The command "/home/dimanne/.cargo/bin/rustup run stable rust-analyzer -v --log-file /home/dimanne/ra.txt --no-log-buffering" terminated with exit code 101.
LanguageClient Rust: Unexpectedly finished

Here is full debug output: https://gist.github.com/DimanNe/bfeaa04e3de22bdd18ab1683227c418f

It looks like both ends with this:

[DEBUG lsp_server::msg] > {"jsonrpc":"2.0","method":"$/progress","params":{"token":"rustAnalyzer/Fetching","value":{"kind":"end"}}}    
[DEBUG lsp_server::msg] > {"jsonrpc":"2.0","id":3,"method":"workspace/semanticTokens/refresh"}    
[DEBUG rust_analyzer::main_loop] will prime caches cause=became quiescent
[DEBUG lsp_server::msg] < {"id":0,"jsonrpc":"2.0","result":null}    
[DEBUG rust_analyzer::main_loop] Instant { tv_sec: 95926, tv_nsec: 9218448 } handle_event(Response(Response { id: RequestId(I32(0)), result: None, error: None }))
[DEBUG rust_analyzer::main_loop] Instant { tv_sec: 95926, tv_nsec: 9223748 } handle_event(Diagnostics([]))
[DEBUG lsp_server::msg] > {"jsonrpc":"2.0","id":4,"method":"window/workDoneProgress/create","params":{"token":"rustAnalyzer/Indexing"}}    
[DEBUG salsa] unwind_if_cancelled: current_revision=R6, pending_revision=R6    
[DEBUG lsp_server::msg] > {"jsonrpc":"2.0","method":"$/progress","params":{"token":"rustAnalyzer/Indexing","value":{"kind":"begin","title":"Indexing","cancellable":false,"percentage":0}}}    
[DEBUG lsp_server::msg] < {"error":{"code":-32601},"id":1,"jsonrpc":"2.0"}

Any suggestions / ideas?

jonas-schievink commented 1 year ago

[ERROR rust_analyzer] failed to find any projects in [AbsPathBuf("/home/dimanne")]

The client is passing your home directory as the root_path config value. That seems like it might cause the issue.