Shopify / ruby-lsp

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

Ruby LSP client couldn't create connection to server (0.16.6) #1994

Closed jake-duchesne closed 2 weeks ago

jake-duchesne commented 2 weeks ago

Description

Reproduction steps

  1. Start the Ruby LSP using VSCode (release or pre-release happens on both)
  2. Immediately met with repeated pop-ups of "Ruby LSP client couldn't create connection to server", "Restarting server failed", "Pending response rejected since connection got disposed"
  3. ruby-lsp failed to start

Other information leading to this and attempted fixes:

Code snippet or error message

2024-04-29 20:42:54.274 [info] (proj) Discovered Ruby version 3.1.5
2024-04-29 20:42:54.274 [info] (proj) Using cached Ruby path: /Users/jakeduchesne/.asdf/installs/ruby/3.1.5/bin
2024-04-29 20:42:54.349 [info] (proj) Activated Ruby environment: gem_home=/Users/jakeduchesne/.gem/ruby/3.1.0@proj, version=3.1.5, yjit=null, gem_root=/Users/jakeduchesne/.asdf/installs/ruby/3.1.5/lib/ruby/gems/3.1.0
2024-04-29 20:42:54.943 [info] (proj) Ruby LSP> Skipping custom bundle setup since /Users/jakeduchesne/code/ezcater/proj/.ruby-lsp/Gemfile.lock already exists and is up to date

2024-04-29 20:42:54.970 [info] (proj) Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle check || bundle install) 1>&2

2024-04-29 20:42:55.362 [info] (proj) The Gemfile's dependencies are satisfied

2024-04-29 20:42:55.904 [info] (proj) /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/prism-0.27.0/lib/prism.rb:81:in `require': incompatible library version - /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/prism-0.27.0/lib/prism/prism.bundle (LoadError)
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/prism-0.27.0/lib/prism.rb:81:in `<top (required)>'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/ruby-lsp-0.16.6/lib/ruby_lsp/internal.rb:18:in `require'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/ruby-lsp-0.16.6/lib/ruby_lsp/internal.rb:18:in `<top (required)>'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/ruby-lsp-0.16.6/exe/ruby-lsp:74:in `require'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/ruby-lsp-0.16.6/exe/ruby-lsp:74:in `<top (required)>'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/bin/ruby-lsp:25:in `load'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/bin/ruby-lsp:25:in `<top (required)>'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/bundler-2.5.9/lib/bundler/cli/exec.rb:58:in `load'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/bundler-2.5.9/lib/bundler/cli/exec.rb:58:in `kernel_load'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/bundler-2.5.9/lib/bundler/cli/exec.rb:23:in `run'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/bundler-2.5.9/lib/bundler/cli.rb:451:in `exec'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/bundler-2.5.9/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/bundler-2.5.9/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/bundler-2.5.9/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/bundler-2.5.9/lib/bundler/cli.rb:34:in `dispatch'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/bundler-2.5.9/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/bundler-2.5.9/lib/bundler/cli.rb:28:in `start'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/bundler-2.5.9/exe/bundle:28:in `block in <top (required)>'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/bundler-2.5.9/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/gems/bundler-2.5.9/exe/bundle:20:in `<top (required)>'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/bin/bundle:25:in `load'
    from /Users/jakeduchesne/.gem/ruby/3.1.0@proj/bin/bundle:25:in `<main>'

2024-04-29 20:42:55.913 [info] (proj) [Error - 8:42:55 PM] Server initialization failed.
2024-04-29 20:42:55.913 [info] (proj)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-04-29 20:42:55.914 [info] (proj) [Info  - 8:42:55 PM] Connection to server got closed. Server will restart.
2024-04-29 20:42:55.914 [info] (proj) true
2024-04-29 20:42:55.914 [info] (proj) [Error - 8:42:55 PM] Ruby LSP client: couldn't create connection to server.
2024-04-29 20:42:55.914 [info] (proj)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-04-29 20:42:55.914 [error] (proj) Error starting the server: Pending response rejected since connection got disposed
2024-04-29 20:42:55.915 [info] (proj) [Error - 8:42:55 PM] Server process exited with code 1.

I've gone through about all the troubleshooting that I can think of or that I've read from the docs, please let me know if I can provide any more useful information.

andyw8 commented 2 weeks ago

Hi @jake-duchesne

Which version manager are you using?

Also, could you try create a separate project using Ruby 3.3 to see if the error happens there?

vinistock commented 2 weeks ago

This does not seem like an issue with the Ruby LSP. It seems gem installations ended up getting into a bad state.

If you run gem install prism, does that succeed? If not, you may want to delete your existing gem installations and then re-install.

The incompatible library issue typically happens when you installed a native extension (like Prism) in one Ruby version and then you're trying to use that installation in a different one.

For example, if you installed the gem and it had its extensions compiled for Ruby 3.1, you cannot reuse the same installation for Ruby 3.2 and that would lead to the error you're seeing.

jake-duchesne commented 2 weeks ago

Hi @jake-duchesne

Which version manager are you using?

Also, could you try create a separate project using Ruby 3.3 to see if the error happens there?

Hi @andyw8, asdf on the version manager and 0.16.6 is working on other projects, so it seems Vinicious is right here - apologies for the misaligned issue. I'll try to figure it out, I'm not super familiar with how gem installations work with extension compilations but gem install prism does work.

Anyways, thanks for the explainer and apologies again.