Shopify / ruby-lsp

An opinionated language server for Ruby
https://shopify.github.io/ruby-lsp/
MIT License
1.59k stars 157 forks source link

The Ruby LSP server crashed 5 times in the last 3 minutes #2196

Closed qupig closed 4 months ago

qupig commented 4 months ago

VSCode Ruby LSP https://marketplace.visualstudio.com/items?itemName=Shopify.ruby-lsp https://github.com/Shopify/ruby-lsp/blob/main/vscode/README.md https://github.com/Shopify/ruby-lsp/blob/main/TROUBLESHOOTING.md

{
    "rubyLsp.formatter": "auto",
    "rubyLsp.rubyVersionManager": {
        "identifier": "none",
    },
}

Both the VSCode TERMINAL and the first line of OUTPUT show the correct SHELL, which is /bin/zsh, but I don't know why it keeps trying /bin/sh in the rest.

2024-06-17 09:34:20.143 [info] (project) Running command: `ruby -W0 -rjson -e 'STDERR.print({ env: ENV.to_h, yjit: !!defined?(RubyVM::YJIT), version: RUBY_VERSION }.to_json)'` in project using shell: /bin/zsh
2024-06-17 09:34:21.309 [info] (project) /bin/sh: ruby-lsp: command not found

2024-06-17 09:34:21.310 [info] (project) [Error - 09:34:21] Server process exited with code 127.
2024-06-17 09:34:21.310 [info] (project) [Error - 09:34:21] Server initialization failed.
2024-06-17 09:34:21.310 [info] (project)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-06-17 09:34:21.310 [info] (project) [Info  - 09:34:21] Connection to server got closed. Server will restart.
2024-06-17 09:34:21.310 [info] (project) true
2024-06-17 09:34:21.310 [info] (project) [Error - 09:34:21] Ruby LSP client: couldn't create connection to server.
2024-06-17 09:34:21.310 [info] (project)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-06-17 09:34:21.311 [error] (project) Error starting the server: Pending response rejected since connection got disposed
2024-06-17 09:34:21.318 [info] (project) /bin/sh: ruby-lsp: command not found

2024-06-17 09:34:21.319 [info] (project) [Error - 09:34:21] Server process exited with code 127.
2024-06-17 09:34:21.319 [info] (project) [Error - 09:34:21] Server initialization failed.
2024-06-17 09:34:21.319 [info] (project)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-06-17 09:34:21.319 [info] (project) [Info  - 09:34:21] Connection to server got closed. Server will restart.
2024-06-17 09:34:21.319 [info] (project) true
2024-06-17 09:34:21.319 [info] (project) [Error - 09:34:21] Ruby LSP client: couldn't create connection to server.
2024-06-17 09:34:21.319 [info] (project)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-06-17 09:34:21.326 [info] (project) /bin/sh: ruby-lsp: command not found

2024-06-17 09:34:21.326 [info] (project) [Error - 09:34:21] Server process exited with code 127.
2024-06-17 09:34:21.326 [info] (project) [Error - 09:34:21] Server initialization failed.
2024-06-17 09:34:21.326 [info] (project)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-06-17 09:34:21.326 [info] (project) [Info  - 09:34:21] Connection to server got closed. Server will restart.
2024-06-17 09:34:21.326 [info] (project) true
2024-06-17 09:34:21.326 [info] (project) [Error - 09:34:21] Ruby LSP client: couldn't create connection to server.
2024-06-17 09:34:21.326 [info] (project)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-06-17 09:34:21.326 [info] (project) [Error - 09:34:21] Restarting server failed
2024-06-17 09:34:21.326 [info] (project)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-06-17 09:34:21.342 [info] (project) /bin/sh: ruby-lsp: command not found

2024-06-17 09:34:21.342 [info] (project) [Error - 09:34:21] Server process exited with code 127.
2024-06-17 09:34:21.343 [info] (project) [Error - 09:34:21] Server initialization failed.
2024-06-17 09:34:21.343 [info] (project)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-06-17 09:34:21.343 [info] (project) [Info  - 09:34:21] Connection to server got closed. Server will restart.
2024-06-17 09:34:21.343 [info] (project) true
2024-06-17 09:34:21.343 [info] (project) [Error - 09:34:21] Ruby LSP client: couldn't create connection to server.
2024-06-17 09:34:21.343 [info] (project)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-06-17 09:34:21.343 [info] (project) [Error - 09:34:21] Restarting server failed
2024-06-17 09:34:21.343 [info] (project)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-06-17 09:34:21.348 [info] (project) /bin/sh: ruby-lsp: command not found

2024-06-17 09:34:21.348 [info] (project) [Error - 09:34:21] Server process exited with code 127.
2024-06-17 09:34:21.349 [info] (project) [Error - 09:34:21] Server initialization failed.
2024-06-17 09:34:21.349 [info] (project)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-06-17 09:34:21.349 [info] (project) [Error - 09:34:21] The Ruby LSP server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
2024-06-17 09:34:21.349 [info] (project) [Error - 09:34:21] Ruby LSP client: couldn't create connection to server.
2024-06-17 09:34:21.349 [info] (project)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-06-17 09:34:21.349 [info] (project) [Error - 09:34:21] Restarting server failed
2024-06-17 09:34:21.349 [info] (project)   Message: Pending response rejected since connection got disposed
  Code: -32097 
vinistock commented 4 months ago

Thank you for the bug report. We'll need more details to be able to understand what is going on.

I see that you have the version manager configured to None. How do you install Ruby? And how do you select the right version? We need to be able to activate the Ruby runtime to launch the gem executable.

The /bin/sh is the default when using NodeJS' exec function. But we do use whatever the VS Code API tells us the shell is.

If you check your default VS Code shell in the integrated terminal (click the down arrow), does it match what you expect (zsh)?

image
qupig commented 4 months ago

How do you install Ruby? And how do you select the right version?

brew install ruby and has been added to PATH in .zchrc.

I don't need to select a version, the global version works fine for me.

check your default VS Code shell in the integrated terminal (click the down arrow)

Interestingly, I don't have a (default) item here, but when I click the + sign it starts a zsh which is the default shell for my account. I assume this is the VSCode initial setup since I've never set it up or modified it.

vinistock commented 4 months ago

We don't source shell scripts automatically, so if you're adding things manually to the PATH in a configuration file, that's the reason why we don't find it.

Sourcing shell scripts has caused a lot of headaches to users in the past and we moved completely away from it.

In this case, you will need to configure custom activation to let the Ruby LSP know how to find the Ruby version:

// Your VS Code settings
{
  // Set the manager to custom
  "rubyLsp.rubyVersionManager": {
    "identifier": "custom",
  },

  // Define a shell script that runs immediately before trying to launch, doing
  // whatever needs to be done to find Ruby. In your case, add the right path
  // to the PATH
  "rubyLsp.customRubyCommand": "PATH=/path/to/ruby/bin:$PATH",
}