ruby-lsp icon indicating copy to clipboard operation
ruby-lsp copied to clipboard

ruby-lsp (0.14.2) not start in vscode

Open danieldocki opened this issue 1 year ago • 3 comments

Ruby version

3.2.3

Code snippet

No response

Description

It seems like it can't find the interpreter, but I noticed that it's searching in the wrong folder, could that be it?

ruby -v
ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [arm64-darwin23]
gem info ruby-lsp

*** LOCAL GEMS ***

ruby-lsp (0.14.2)
    Author: Shopify
    Homepage: https://github.com/Shopify/ruby-lsp
    License: MIT
    Installed at: /Users/danieldocki/.asdf/installs/ruby/3.2.3/lib/ruby/gems/3.2.0

    An opinionated language server for Ruby
2024-02-22 21:18:31.446 [info] Discovered Ruby version 3.2.3
2024-02-22 21:18:31.446 [info] Using cached Ruby path: /Users/danieldocki/.asdf/installs/ruby/3.2.3/bin
2024-02-22 21:18:31.496 [info] Activated Ruby environment: gem_home=/Users/danieldocki/.gem/ruby/3.2.0, version=3.2.3, yjit=constant, gem_root=/Users/danieldocki/.asdf/installs/ruby/3.2.3/lib/ruby/gems/3.2.0
2024-02-22 21:18:31.726 [info] /bin/sh: /Users/danieldocki/.gem/ruby/3.2.0/bin/ruby-lsp: /Users/danieldocki/.asdf/installs/ruby/3.2.2/bin/ruby: bad interpreter: No such file or directory

2024-02-22 21:18:31.734 [info] [Error - 9:18:31 PM] Server process exited with code 126.
2024-02-22 21:18:31.734 [info] [Error - 9:18:31 PM] Server initialization failed.
2024-02-22 21:18:31.734 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-02-22 21:18:31.734 [info] [Info  - 9:18:31 PM] Connection to server got closed. Server will restart.
2024-02-22 21:18:31.734 [info] true
2024-02-22 21:18:31.734 [info] [Error - 9:18:31 PM] Ruby LSP client: couldn't create connection to server.
2024-02-22 21:18:31.734 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 

Expected output

Start the server

danieldocki avatar Feb 23 '24 00:02 danieldocki

Thank you for the bug report! This is an interesting one. The only time I've seen it was when I had upgraded my Ruby version and deleted the previous installation that was already cached in the extension (which we indeed need to fix).

To fix it, I took these steps:

  • Completely removed the directory where gems were installed to re-install all of them from scratch. E.g.: rm -rf ~/.gem/ruby/3.2.2
  • Re-installed gems bundle install
  • Triggered the Ruby LSP: change Ruby version command in VS Code and picked clear cache

Did you do the same? Have you recently upgraded Ruby and deleted the existing installation? Please let me know if you remember which steps led to this outcome. And if you decide to try to fix it with the same steps I took, please let us know if it worked.

vinistock avatar Feb 28 '24 16:02 vinistock

I had recently updated Ruby from version 3.2.2 to 3.2.3 and then removed the previous installation of version 3.2.2, which led to the errors mentioned. By following the recommended steps, I was able to successfully resolve the issue.

Thanks @vinistock

danieldocki avatar Feb 29 '24 13:02 danieldocki

Nice. So exactly the same issue I had previously.

Yeah, we need to better handle when a cached Ruby gets deleted, so I'll keep this issue open.

vinistock avatar Feb 29 '24 15:02 vinistock