Skip to content

VsCodium: Error code -32097 can't connect to the server #1216

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

Closed
FlameSniper opened this issue Nov 25, 2023 · 10 comments
Closed

VsCodium: Error code -32097 can't connect to the server #1216

FlameSniper opened this issue Nov 25, 2023 · 10 comments
Labels
bug Something isn't working pinned This issue or pull request is pinned and won't be marked as stale

Comments

@FlameSniper
Copy link

Ruby version

3.0.6-1

Code snippet

The output by ruby-lsp. All i did was search for it and install it on my system

Ruby LSP> Checking if asdf is available on the path with command: /bin/bash -ic 'asdf --version'
Ruby LSP> Checking if chruby is available on the path with command: /bin/bash -ic 'chruby --version'
Ruby LSP> Checking if rbenv is available on the path with command: /bin/bash -ic 'rbenv --version'
Ruby LSP> Checking if rvm is available on the path with command: /bin/bash -ic 'rvm --version'
Ruby LSP> Discovered version manager none
Ruby LSP> Trying to activate Ruby environment with command: /bin/bash -ic 'ruby -rjson -e "printf(%{RUBY_ENV_ACTIVATE%sRUBY_ENV_ACTIVATE}, JSON.dump(ENV.to_h))"' inside directory: /home/lucas/Programas/Codium/Ruby
/bin/sh: línea 1: ruby-lsp: orden no encontrada
[Error - 19:35:57] Server process exited with code 127.
[Error - 19:35:57] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 19:35:57] Connection to server got closed. Server will restart.
true
[Error - 19:35:57] Ruby LSP client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
/bin/sh: línea 1: ruby-lsp: orden no encontrada
[Error - 19:35:57] Server process exited with code 127.
[Error - 19:35:57] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 19:35:57] Connection to server got closed. Server will restart.
true
[Error - 19:35:57] Ruby LSP client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
Error restarting the server: Pending response rejected since connection got disposed
/bin/sh: línea 1: ruby-lsp: orden no encontrada
[Error - 19:35:57] Server process exited with code 127.
[Error - 19:35:57] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 19:35:57] Connection to server got closed. Server will restart.
true
[Error - 19:35:57] Ruby LSP client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 19:35:57] Restarting server failed
Message: Pending response rejected since connection got disposed
Code: -32097
/bin/sh: línea 1: ruby-lsp: orden no encontrada
[Error - 19:35:57] Server process exited with code 127.
[Error - 19:35:57] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 19:35:57] Connection to server got closed. Server will restart.
true
[Error - 19:35:57] Ruby LSP client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 19:35:57] Restarting server failed
Message: Pending response rejected since connection got disposed
Code: -32097
/bin/sh: línea 1: ruby-lsp: orden no encontrada
[Error - 19:35:57] Server process exited with code 127.
[Error - 19:35:57] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 19:35:57] The Ruby LSP server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - 19:35:57] Ruby LSP client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 19:35:57] Restarting server failed
Message: Pending response rejected since connection got disposed
Code: -32097

Description

Using vscodium 1.84.2.23319-1 in Arch Linux, provided via the AUR.
The only other extension installed is Dracula Official

Expected output

That everything works as intended.

@FlameSniper FlameSniper added the bug Something isn't working label Nov 25, 2023
@vinistock
Copy link
Member

Thank you for the bug report. Based on this line

/bin/sh: línea 1: ruby-lsp: orden no encontrada

It looks like this is the same issue as #1705. Can you try opening VS Code from the terminal with code . to see if the issue goes away?

If it does, then it's certainly related to that bug with VS Code not finding the correct default shell.

@FlameSniper
Copy link
Author

I tried to launch it from the terminal by typing vscodium. No difference, it gives the same error code and no kind of output, not even debug information in the terminal running vscodium

Ruby LSP> Checking if asdf is available on the path with command: /bin/bash -ic 'asdf --version'
Ruby LSP> Checking if chruby is available on the path with command: /bin/bash -ic 'chruby --version'
Ruby LSP> Checking if rbenv is available on the path with command: /bin/bash -ic 'rbenv --version'
Ruby LSP> Checking if rvm is available on the path with command: /bin/bash -ic 'rvm --version'
Ruby LSP> Discovered version manager none
Ruby LSP> Trying to activate Ruby environment with command: /bin/bash -ic 'ruby -rjson -e "printf(%{RUBY_ENV_ACTIVATE%sRUBY_ENV_ACTIVATE}, JSON.dump(ENV.to_h))"' inside directory: /home/lucas/Programas/Codium/Ruby
[Error - 10:03:42] Client Ruby LSP: connection to server is erroring.
write EPIPE
Shutting down server.
[Error - 10:03:42] Client Ruby LSP: connection to server is erroring.
write EPIPE
[Error - 10:03:42] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: starting
at Hd.shutdown (/home/lucas/.vscode-oss/extensions/shopify.ruby-lsp-0.4.13-universal/out/extension.js:41:8468)
at Hd.stop (/home/lucas/.vscode-oss/extensions/shopify.ruby-lsp-0.4.13-universal/out/extension.js:41:8047)
at Hd.stop (/home/lucas/.vscode-oss/extensions/shopify.ruby-lsp-0.4.13-universal/out/extension.js:44:38188)
at Hd.handleConnectionError (/home/lucas/.vscode-oss/extensions/shopify.ruby-lsp-0.4.13-universal/out/extension.js:43:63)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[Error - 10:03:42] Server initialization failed.
Message: write EPIPE
Code: -32099
[Error - 10:03:42] Ruby LSP client: couldn't create connection to server.
Message: write EPIPE
Code: -32099
Error restarting the server: write EPIPE
[Info - 10:03:42] Connection to server got closed. Server will restart.
true
/bin/sh: línea 1: ruby-lsp: orden no encontrada
[Error - 10:03:42] Server process exited with code 127.
[Error - 10:03:42] Client Ruby LSP: connection to server is erroring.
write EPIPE
Shutting down server.
[Error - 10:03:42] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: starting
at Hd.shutdown (/home/lucas/.vscode-oss/extensions/shopify.ruby-lsp-0.4.13-universal/out/extension.js:41:8468)
at Hd.stop (/home/lucas/.vscode-oss/extensions/shopify.ruby-lsp-0.4.13-universal/out/extension.js:41:8047)
at Hd.stop (/home/lucas/.vscode-oss/extensions/shopify.ruby-lsp-0.4.13-universal/out/extension.js:44:38188)
at Hd.handleConnectionError (/home/lucas/.vscode-oss/extensions/shopify.ruby-lsp-0.4.13-universal/out/extension.js:43:63)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[Error - 10:03:42] Server initialization failed.
Message: write EPIPE
Code: -32099
[Error - 10:03:42] Ruby LSP client: couldn't create connection to server.
Message: write EPIPE
Code: -32099
[Error - 10:03:42] Restarting server failed
Message: write EPIPE
Code: -32099
[Info - 10:03:42] Connection to server got closed. Server will restart.
true
/bin/sh: línea 1: ruby-lsp: orden no encontrada
[Error - 10:03:42] Server process exited with code 127.
/bin/sh: línea 1: ruby-lsp: orden no encontrada
[Error - 10:03:42] Server process exited with code 127.
[Error - 10:03:42] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 10:03:42] Connection to server got closed. Server will restart.
true
[Error - 10:03:42] Ruby LSP client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
/bin/sh: línea 1: ruby-lsp: orden no encontrada
[Error - 10:03:42] Server process exited with code 127.
[Error - 10:03:42] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 10:03:42] Connection to server got closed. Server will restart.
true
[Error - 10:03:42] Ruby LSP client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 10:03:42] Restarting server failed
Message: Pending response rejected since connection got disposed
Code: -32097
/bin/sh: línea 1: ruby-lsp: orden no encontrada
[Error - 10:03:42] Server process exited with code 127.
[Error - 10:03:42] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 10:03:42] The Ruby LSP server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - 10:03:42] Ruby LSP client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 10:03:42] Restarting server failed
Message: Pending response rejected since connection got disposed
Code: -32097

@froyo-naux
Copy link

froyo-naux commented Dec 7, 2023

output say you not use any ruby version manager.so find ruby-lsp in your system gem folder. but not found

maybe gem bin folder not in your $PATH.so not found ruby-lsp

  1. get gem bin path
gem env

image

  1. add EXECUTABLE DIRECTORY path to your shell path
  2. source ~/.zshrc or some profile. or reopen terminal

image

@vinistock
Copy link
Member

vinistock commented Dec 7, 2023

I don't believe that's the root cause of the problem. If you look at

/bin/sh: línea 1: ruby-lsp: orden no encontrada

Something is causing VS Code to think that /bin/sh is the default shell. If we pick the wrong shell, then the version manager and environment variables will likely not be available, leading to the error.

It could be the same case as this VS Code issue microsoft/vscode#88736.

Copy link
Contributor

github-actions bot commented Feb 6, 2024

This issue is being marked as stale because there was no activity in the last 2 months

@github-actions github-actions bot added the Stale label Feb 6, 2024
@vinistock vinistock added pinned This issue or pull request is pinned and won't be marked as stale and removed Stale labels Feb 6, 2024
@vladhadzhiyski
Copy link

Thank you for the bug report. Based on this line

/bin/sh: línea 1: ruby-lsp: orden no encontrada

It looks like this is the same issue as #1705. Can you try opening VS Code from the terminal with code . to see if the issue goes away?

If it does, then it's certainly related to that bug with VS Code not finding the correct default shell.

I'm also experiencing the same issue and I'm not able to figure it out for some reason... 😞

Any ideas why my rbenv is not recognized in the VS Code terminal?

2024-04-04 15:19:48.613 [info] Checking if asdf is available on the path with command: /bin/zsh -i -c 'asdf --version'
2024-04-04 15:19:49.240 [info] Checking if chruby is available on the path with command: /bin/zsh -i -c 'chruby --version'
2024-04-04 15:19:49.651 [info] Checking if rbenv is available on the path with command: /bin/zsh -i -c 'rbenv --version'
2024-04-04 15:19:50.059 [info] Discovered version manager rbenv

And I do have rbenv installed with the right ruby version for the project - installed locally and globally:

$ /bin/zsh -i -c 'rbenv --version'
rbenv 1.2.0

@vinistock
Copy link
Member

@Raxelgrande I took another look at this issue and I think I now understand the issue. You're not using any version manager, but rather installing Ruby through Homebrew. With no version manager, we don't perform automatic detection of the Ruby version, but on the latest v0.7.0 version of the extension you can manually select your Ruby installation, which should fix your issue.

@vladhadzhiyski your issue seems to be a different one, but if the problem is that rbenv is not recognized inside of the integrated terminal, then that is unrelated to the Ruby LSP and likely an issue with your shell configurations.

@celgost
Copy link

celgost commented Jun 4, 2024

Hey there, Have been getting the issue lately while I never got it before:

Automatic Ruby environment activation with rbenv failed: 
Command failed: 
rbenv exec ruby -W0 -rjson -e 'STDERR.print({env: ENV.to_h,yjit:!!defined?(RubyVM::YJIT),version:RUBY_VERSION}.to_json)'
/bin/sh: line 1: rbenv: command not found

I'm using zsh, and in VSCode, integrated terminal is on zsh. I've tried the code . workaround and it works, but it is quite annoying to do so. Impacting my workflow.

Have also been trying to launch rbenv in /bin/sh and it works there as I installed rbenv for both zsh and bash.

I'm running out of ideas, if you have any @vinistock

@vinistock
Copy link
Member

Are you sourcing rbenv or adding it to your PATH in shell scripts?

The VS Code process doesn't source those automatically which would explain why when you open the editor through the icon, then rbenv is not present in the PATH.

When you launch it through the terminal, it was your terminal shell that sourced the scripts already and running code . makes the VS Code process inherit the environment, which then makes everything work.

@celgost
Copy link

celgost commented Jun 6, 2024

Hey, so actually this was a weird bug and quite unrelated to the original issue.

I'm on AwesomeWM, so to start apps I use built-in functions called spawn and spawn_with_shell in a config file and then assign it to a hotkey. When using the hotkey (and thus forementioned functions), rbenv was not accessible inside VSCode.

However, to my surprise, when clicking on the icon in app menu/launching code.desktop file, everything was working as intended.

So I figured it would be better to start VSCode with the .desktop file directly in my rc.lua config with this function call: awful.util.spawn("gtk-launch code.desktop").

Sorry for bothering you and going on a tangent. But you helped me by giving me the idea to launch VSCode through the app menu!

It might be related to how the spawn_with_shell function handles starting apps and the shell associated with it. But I might just go post a bug issue on the AwesomeWM Github instead!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pinned This issue or pull request is pinned and won't be marked as stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants