fannheyward / coc-rust-analyzer

rust-analyzer extension for coc.nvim
MIT License
1.13k stars 39 forks source link

Rust Analyzer Language Server client: couldn't create connection to server. #1151

Closed jloxfo2 closed 1 year ago

jloxfo2 commented 1 year ago

Running into an issue with client failing to connect to the language server. It was previously working, but broke at some point. The only notable thing that occurred in that time was running rustup update to move to 1.70. Also tried uninstalling and reinstalling coc-rust-analyzer, coc.nvim, and rust.vim, but without any success.

Error seen after starting opening a rust source file in vim:

[coc.nvim] Rust Analyzer Language Server client: couldn't create connection to server.

What's the output of :CocInfo

## versions

vim version: VIM - Vi IMproved 9.0 9000813
node version: v16.20.0
coc.nvim version: 0.0.82-b7375d5f 2023-01-30 05:09:03 +0800
coc.nvim directory: /local/home/$USER/.vim/plugged/coc.nvim
term: dumb
platform: linux

## Log of coc.nvim

2023-06-06T07:09:26.424 INFO (pid:43707) [plugin] - coc.nvim initialized with node: v16.20.0 after 176
2023-06-06T07:09:26.425 INFO (pid:43707) [services] - LanguageClient Rust Analyzer Language Server
state change: stopped => starting
2023-06-06T07:09:26.433 INFO (pid:43707) [language-client-index] - Language server "rust-analyzer"
started with 43744
2023-06-06T07:09:26.444 ERROR (pid:43707) [language-client] - Sending request failed.
2023-06-06T07:09:26.445 INFO (pid:43707) [services] - LanguageClient Rust Analyzer Language Server
state change: starting => stopped
2023-06-06T07:09:26.445 INFO (pid:43707) [services] - LanguageClient Rust Analyzer Language Server
state change: stopped => starting
2023-06-06T07:09:26.445 ERROR (pid:43707) [language-client-client] - Server rust-analyzer
initialization failed. jh [Error]: Pending response rejected since connection got disposed
    at Object.dispose (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:51:4592)
    at Object.dispose (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:241:6209)
    at Nd.handleConnectionClosed (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:15575)
    at Nd.handleConnectionClosed (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:248:3561)
    at t (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:15224)
    at yT.invoke (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:15230)
    at Qe (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:25:6504)
    at yT.invoke (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:15230) {
  code: -32097,
  data: undefined
}
2023-06-06T07:09:26.447 INFO (pid:43707) [services] - LanguageClient Rust Analyzer Language Server
state change: starting => stopped
2023-06-06T07:09:26.448 ERROR (pid:43707) [server] - unhandledRejection  Promise {
  <rejected> jh [Error]: Pending response rejected since connection got disposed
      at Object.dispose (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:51:4592)
      at Object.dispose (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:241:6209)
      at Nd.handleConnectionClosed (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:
15575)
      at Nd.handleConnectionClosed (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:248:3561)
      at t (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:15224)
      at yT.invoke (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:14460)
      at lc.fire (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:15230)
      at Qe (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:25:6504)
      at yT.invoke (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:14460)
      at lc.fire (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:15230) {
    code: -32097,
    data: undefined
  }
} jh [Error]: Pending response rejected since connection got disposed
    at Object.dispose (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:51:4592)
    at Object.dispose (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:241:6209)
    at Nd.handleConnectionClosed (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:15575)
    at Nd.handleConnectionClosed (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:248:3561)
    at t (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:15224)
    at yT.invoke (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:15230)
    at Qe (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:25:6504)
    at yT.invoke (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:15230) {
  code: -32097,
  data: undefined
}
2023-06-06T07:09:26.451 INFO (pid:43707) [language-client-index] - Language server "rust-analyzer"
started with 43745
2023-06-06T07:09:26.453 ERROR (pid:43707) [language-client] - Sending request failed.
2023-06-06T07:09:26.453 INFO (pid:43707) [services] - LanguageClient Rust Analyzer Language Server
state change: stopped => starting
2023-06-06T07:09:26.454 ERROR (pid:43707) [language-client-client] - Server rust-analyzer
initialization failed. jh [Error]: Pending response rejected since connection got disposed
    at Object.dispose (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:51:4592)
    at Object.dispose (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:241:6209)
    at Nd.handleConnectionClosed (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:15575)
    at Nd.handleConnectionClosed (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:248:3561)
    at t (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:15224)
    at yT.invoke (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:15230)
    at Qe (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:25:6504)
    at yT.invoke (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:15230) {
  code: -32097,
  data: undefined
}
2023-06-06T07:09:26.454 INFO (pid:43707) [services] - LanguageClient Rust Analyzer Language Server
state change: starting => stopped
2023-06-06T07:09:26.454 ERROR (pid:43707) [services] - Server rust-analyzer failed to start: jh
[Error]: Pending response rejected since connection got disposed
    at Object.dispose (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:51:4592)
    at Object.dispose (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:241:6209)
    at Nd.handleConnectionClosed (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:15575)
    at Nd.handleConnectionClosed (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:248:3561)
    at t (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:15224)
    at yT.invoke (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:15230)
    at Qe (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:25:6504)
    at yT.invoke (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:15230) {
  code: -32097,
  data: undefined
}
2023-06-06T07:09:26.459 INFO (pid:43707) [language-client-index] - Language server "rust-analyzer"
started with 43747
2023-06-06T07:09:26.463 ERROR (pid:43707) [language-client] - Sending request failed.
2023-06-06T07:09:26.463 INFO (pid:43707) [services] - LanguageClient Rust Analyzer Language Server
state change: stopped => starting
2023-06-06T07:09:26.463 ERROR (pid:43707) [language-client-client] - Server rust-analyzer
initialization failed. jh [Error]: Pending response rejected since connection got disposed
    at Object.dispose (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:51:4592)
    at Object.dispose (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:241:6209)
    at Nd.handleConnectionClosed (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:15575)
    at Nd.handleConnectionClosed (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:248:3561)
    at t (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:15224)
    at yT.invoke (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:15230)
    at Qe (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:25:6504)
    at yT.invoke (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:15230) {
  code: -32097,
  data: undefined
}
2023-06-06T07:09:26.463 INFO (pid:43707) [services] - LanguageClient Rust Analyzer Language Server
state change: starting => stopped
2023-06-06T07:09:26.466 INFO (pid:43707) [language-client-index] - Language server "rust-analyzer"
started with 43748
2023-06-06T07:09:26.468 ERROR (pid:43707) [language-client] - Sending request failed.
2023-06-06T07:09:26.468 ERROR (pid:43707) [language-client-client] - Server rust-analyzer
initialization failed. jh [Error]: Pending response rejected since connection got disposed
    at Object.dispose (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:51:4592)
    at Object.dispose (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:241:6209)
    at Nd.handleConnectionClosed (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:15575)
    at Nd.handleConnectionClosed (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:248:3561)
    at t (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:15224)
    at yT.invoke (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:15230)
    at Qe (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:25:6504)
    at yT.invoke (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:15230) {
  code: -32097,
  data: undefined
}
2023-06-06T07:09:26.636 INFO (pid:43707) [attach] - receive notification: highlight []
2023-06-06T07:09:28.916 INFO (pid:43707) [attach] - receive notification: showInfo []
2023-06-06T07:09:29.231 INFO (pid:43707) [attach] - receive notification: highlight []
2023-06-06T07:09:31.377 ERROR (pid:43707) [timing] - activate coc-rust-analyzer timeout after 5000ms
2023-06-06T07:09:33.147 INFO (pid:43707) [attach] - receive notification: runCommand [ 'rust-analyzer.
serverVersion' ]
2023-06-06T07:09:33.448 INFO (pid:43707) [attach] - receive notification: highlight []
2023-06-06T07:09:36.696 INFO (pid:43707) [attach] - receive notification: highlight []
2023-06-06T07:09:41.156 INFO (pid:43707) [attach] - receive notification: showInfo []
2023-06-06T07:09:41.467 INFO (pid:43707) [attach] - receive notification: highlight []
2023-06-06T07:09:44.193 INFO (pid:43707) [attach] - receive notification: highlight []
2023-06-06T07:09:45.501 INFO (pid:43707) [attach] - receive notification: highlight []
2023-06-06T07:09:47.222 INFO (pid:43707) [attach] - receive notification: showInfo []

What's the output of :CocCommand rust-analyzer.serverVersion There is no output, although we do see it in the CocInfo logs.

What's your coc-rust-analyzer version? You can get it from :CocList extensions

+ coc-rust-analyzer 0.73.0 /local~/.config/coc/extensions/node_modules/coc-rust-analyzer
+ coc-json 1.8.0 /local~/.config/coc/extensions/node_modules/coc-json
fannheyward commented 1 year ago

rust-analyzer fails to start. As you see in the logs, rust-analyzer started several times, but all failed.

There is no output, although we do see it in the CocInfo logs.

Where's it?

Do you have rust-analyzer installed manually? By default, coc-rust-analyzer will download rust-analyzer to ~/.config/coc/extensions/coc-rust-analyzer-data/rust-analyzer. What's the output:

~/.config/coc/extensions/coc-rust-analyzer-data/rust-analyzer --version

jloxfo2 commented 1 year ago

I think that command shows the problem. It seems to reside in the libc version,

% ~/.config/coc/extensions/coc-rust-analyzer-data/rust-analyzer --version
/home/$USER/.config/coc/extensions/coc-rust-analyzer-data/rust-analyzer: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /home/$USER/.config/coc/extensions/coc-rust-analyzer-data/rust-analyzer)

Checking the version of libc,

% ldd --version
ldd (GNU libc) 2.26

One thing that's still not clear is why it was working before if there is such a dependency failure.


Verbose logging output, checking :CocCommand workspace.showOutput:

[Error - 19:31:17.367] Connection to server Rust Analyzer Language Server is erroring, write EPIPE. Shutting down server.
Error: write EPIPE
    at afterWriteDispatched (node:internal/stream_base_commons:160:15)
    at writeGeneric (node:internal/stream_base_commons:151:3)
    at Socket._writeGeneric (node:net:905:11)
    at Socket._write (node:net:917:8)
    at writeOrBuffer (node:internal/streams/writable:391:12)
    at _write (node:internal/streams/writable:332:10)
    at Socket.Writable.write (node:internal/streams/writable:336:10)
    at /local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:3107
    at new Promise (<anonymous>)
    at ZD.write (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:3028)
[Error - 19:31:17.368] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: 1
    at Nd.shutdown (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:13537)
    at Nd.stop (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:13332)
    at Nd.stop (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:248:3029)
    at Nd.handleConnectionError (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:16527)
    at e (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:15182)
    at /local/home/$USER/.vim/plugged/coc.nvim/build/index.js:241:5636
    at yT.invoke (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:15230)
    at Dn (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:25:6576)
    at yT.invoke (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:14460)
[Info  - 19:31:17.368] Connection to server got closed. Server will restart.
[Error - 19:31:17.369] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097
[Error - 19:31:17.371] Rust Analyzer Language Server client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097
/local/home/$USER/.config/coc/extensions/coc-rust-analyzer-data/rust-analyzer: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /local/home/$USER/.config/coc/extensions/coc-rust-analyzer-
[Error - 19:31:17.377] /local/home/$USER/.config/coc/extensions/coc-rust-analyzer-data/rust-analyzer exited with code: 1
[Error - 19:31:17.377] /local/home/$USER/.config/coc/extensions/coc-rust-analyzer-data/rust-analyzer exited with code: 1
[Info  - 19:31:17.377] Connection to server got closed. Server will restart.
[Error - 19:31:17.377] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097
[Error - 19:31:17.378] Rust Analyzer Language Server client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097
/local/home/$USER/.config/coc/extensions/coc-rust-analyzer-data/rust-analyzer: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /local/home/$USER/.config/coc/extensions/coc-rust-analyzer-
[Error - 19:31:17.385] Connection to server Rust Analyzer Language Server is erroring, write EPIPE. Shutting down server.
Error: write EPIPE
    at afterWriteDispatched (node:internal/stream_base_commons:160:15)
    at writeGeneric (node:internal/stream_base_commons:151:3)
    at Socket._writeGeneric (node:net:905:11)
    at Socket._write (node:net:917:8)
    at writeOrBuffer (node:internal/streams/writable:391:12)
    at _write (node:internal/streams/writable:332:10)
    at Socket.Writable.write (node:internal/streams/writable:336:10)
    at /local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:3107
    at new Promise (<anonymous>)
    at ZD.write (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:3028)
[Error - 19:31:17.385] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: 2
    at Nd.shutdown (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:13537)
    at Nd.stop (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:13332)
    at Nd.stop (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:248:3029)
    at Nd.handleConnectionError (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:16527)
    at e (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:244:15182)
    at /local/home/$USER/.vim/plugged/coc.nvim/build/index.js:241:5636
    at yT.invoke (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:15230)
    at Dn (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:25:6576)
    at yT.invoke (/local/home/$USER/.vim/plugged/coc.nvim/build/index.js:24:14460)
[Info  - 19:31:17.385] Connection to server got closed. Server will restart.
jloxfo2 commented 1 year ago

So I was able to root cause the issue to the rust-analyzer binary itself. The binary version being used was not compatible with my libc version (v2.26). It may have been working before running rustup due to rust-analyzer now shipping with rustup [0]. In any case, using a different rust-analyzer binary and setting "rust-analyzer.server.path" in the CocConfig to point to the binary solved the issue.

[0] https://github.com/rust-lang/rust/pull/98640/

crazyoptimist commented 1 year ago

I faced the same issue, was able to resolve by running:

mkdir -p ~/.local/bin
curl -L https://github.com/rust-lang/rust-analyzer/releases/latest/download/rust-analyzer-x86_64-unknown-linux-gnu.gz | gunzip -c - > ~/.local/bin/rust-analyzer
chmod +x ~/.local/bin/rust-analyzer