Skip to content
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

store.rb:48:in `binread': no implicit conversion of nil into String (TypeError) #1897

Closed
rgaufman opened this issue Apr 7, 2024 · 41 comments · Fixed by #1901 or #1915
Closed

store.rb:48:in `binread': no implicit conversion of nil into String (TypeError) #1897

rgaufman opened this issue Apr 7, 2024 · 41 comments · Fixed by #1901 or #1915
Assignees
Labels
bug Something isn't working

Comments

@rgaufman
Copy link

rgaufman commented Apr 7, 2024

Description

I'm getting this in Visual Studio

ruby-lsp0.12.2
visual studio code 1.87.2

Seems need to add nil handling there?

2024-04-07 15:34:29.284 [info] (tetherx) Ruby LSP> Skipping custom bundle setup since /Users/hackeron/Development/TetherX/tetherx/.ruby-lsp/Gemfile.lock already exists and is up to date

2024-04-07 15:34:29.294 [info] (tetherx) 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-07 15:34:29.435 [info] (tetherx) The Gemfile's dependencies are satisfied

2024-04-07 15:34:30.571 [info] (tetherx) Initializing Ruby LSP v0.16.2...

2024-04-07 15:34:30.585 [info] (tetherx) Finished initializing Ruby LSP!

2024-04-07 15:34:30.591 [info] (tetherx) /opt/homebrew/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.16.2/lib/ruby_lsp/store.rb:48:in `binread': no implicit conversion of nil into String (TypeError)

      set(uri: uri, source: File.binread(path), version: 0)
                                         ^^^^
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.16.2/lib/ruby_lsp/store.rb:48:in `get'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11332/lib/types/private/methods/_methods.rb:279:in `bind_call'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11332/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.16.2/lib/ruby_lsp/base_server.rb:55:in `block (2 levels) in start'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.16.2/lib/ruby_lsp/base_server.rb:46:in `synchronize'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.16.2/lib/ruby_lsp/base_server.rb:46:in `block in start'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/language_server-protocol-3.17.0.3/lib/language_server/protocol/transport/io/reader.rb:20:in `read'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.16.2/lib/ruby_lsp/base_server.rb:39:in `start'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11332/lib/types/private/methods/_methods.rb:279:in `bind_call'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11332/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.16.2/exe/ruby-lsp:89:in `<top (required)>'
	from /opt/homebrew/lib/ruby/gems/3.3.0/bin/ruby-lsp:25:in `load'
	from /opt/homebrew/lib/ruby/gems/3.3.0/bin/ruby-lsp:25:in `<top (required)>'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/cli/exec.rb:58:in `load'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/cli/exec.rb:23:in `run'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/cli.rb:451:in `exec'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/cli.rb:34:in `dispatch'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/cli.rb:28:in `start'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/exe/bundle:28:in `block in <top (required)>'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from /opt/homebrew/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/exe/bundle:20:in `<top (required)>'
	from /opt/homebrew/opt/ruby/bin/bundle:25:in `load'
	from /opt/homebrew/opt/ruby/bin/bundle:25:in `<main>'

2024-04-07 15:34:30.594 [info] (tetherx) [Error - 15:34:30] Server process exited with code 1.
2024-04-07 15:34:30.595 [info] (tetherx) [Error - 15:34:30] The Ruby LSP server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
@rgaufman rgaufman added the bug Something isn't working label Apr 7, 2024
@tgaff
Copy link

tgaff commented Apr 8, 2024

Also seeing this exact error and unable to start server.

chruby, ruby 3.2.3, OSX-intel
ruby-lsp 0.16.2

@rubyroobs
Copy link

Following - I am getting an identical error with ruby-lsp 0.16.2 on Apple Silicon / ruby 3.2.3

@vinistock
Copy link
Member

Thank you for the bug report. When does this happen? Is it in case you have files opened in the editor that no longer exist? Or is it when you open any file? What steps do you take to reproduce this?

@rgaufman
Copy link
Author

rgaufman commented Apr 8, 2024

I'm not 100% sure, I'm just constantly nagged by Visual Studio with this exception seemingly at random but it seems just adding simple nil handling there should fix it :)

@andyw8
Copy link
Contributor

andyw8 commented Apr 8, 2024

@rgaufman could you try enable logging as described here. That should help us understand which request is causing this.

@rgaufman
Copy link
Author

rgaufman commented Apr 8, 2024

I've uninstalled the Ruby LSP extension temporarily as it was nagging me constantly, I'll re-install and check.

But considering we know where it is failing, there are multiple people impacted by this across platforms, and it would be quite easy to add nil handling there, any motivation not to handle nil there?

EDIT: I re-installed the extension and enabled server trace verbose, but for now not being nagged with errors, possible re-installing helped? - will keep an eye out and report back.

@vinistock
Copy link
Member

But considering we know where it is failing, there are multiple people impacted by this across platforms, and it would be quite easy to add nil handling there, any motivation not to handle nil there?

We need to first understand what situation causes the URI's path to be nil. Maybe the issue is that it shouldn't be nil and the bug is elsewhere.

Maybe this only happens for files in the untitled URI scheme (when you open a file, but haven't saved it yet), in which case the more appropriate solution is to treat untitled files differently than how we treat files with the file scheme.

For the others that have replied here, are you on the latest version of both the extension and server?

@agrobbin
Copy link

agrobbin commented Apr 8, 2024

I've been running into this a bunch recently as well, and definitely tend to keep a couple of untitled / working files open (as a sort of scratchpad). I am running v0.5.17 of the extension, and v0.16.2 of the ruby-lsp gem.

@vinistock
Copy link
Member

@agrobbin can you describe exact the steps you take to reproduce this? I'm not able to reproduce this by creating a new untitled Ruby file.

@agrobbin
Copy link

agrobbin commented Apr 8, 2024

I've not done anything special or unique AFAIK. I'm running the VS Code extension and when I start it up with untitled files (some Markdown, some Ruby), I get this error. It happens on startup and quickly gives up after 5 failed attempts.

@sradu
Copy link

sradu commented Apr 8, 2024

I'm having this exact problem on the latest macOS (upgraded yesterday), ruby 3.2.3. It first started with some 'ruby-lsp needs yjit support' error. When I recompiled ruby it started erroring with: .gem/ruby/3.2.3/gems/ruby-lsp-0.16.2/lib/ruby_lsp/store.rb:48:in binread': no implicit conversion of nil into String (TypeError)`.

@vinistock
Copy link
Member

Thanks for all the information. The associated PR should fix this issue.

@agrobbin
Copy link

agrobbin commented Apr 8, 2024

Thanks @vinistock! Will try it as soon as it's released and report back.

@rubyroobs
Copy link

Just in case anyone else also has the same issue after updating ruby-lsp to 0.16.3 through the extension, I also had to close all my open tabs and restart VSCode for the error to go away.

Thank you @vinistock for the quick fix here!

@agrobbin
Copy link

@vinistock I tested v0.16.3 in VS Code, closing all untitled files and restarting, and unfortunately am still running into it when I open a new untitled file:

2024-04-10 08:37:41.129 [info] (test-repo) /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.16.3/lib/ruby_lsp/store.rb:44:in `binread': no implicit conversion of nil into String (TypeError)

      set(uri: uri, source: File.binread(path), version: 0)
                                         ^^^^
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.16.3/lib/ruby_lsp/store.rb:44:in `get'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11338/lib/types/private/methods/_methods.rb:279:in `bind_call'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11338/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.16.3/lib/ruby_lsp/base_server.rb:55:in `block (2 levels) in start'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.16.3/lib/ruby_lsp/base_server.rb:46:in `synchronize'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.16.3/lib/ruby_lsp/base_server.rb:46:in `block in start'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/language_server-protocol-3.17.0.3/lib/language_server/protocol/transport/io/reader.rb:20:in `read'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.16.3/lib/ruby_lsp/base_server.rb:39:in `start'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11338/lib/types/private/methods/_methods.rb:279:in `bind_call'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11338/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.16.3/exe/ruby-lsp:89:in `<top (required)>'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/bin/ruby-lsp:25:in `load'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/bin/ruby-lsp:25:in `<top (required)>'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/cli/exec.rb:58:in `load'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/cli/exec.rb:23:in `run'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/cli.rb:451:in `exec'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/cli.rb:34:in `dispatch'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/cli.rb:28:in `start'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/exe/bundle:28:in `block in <top (required)>'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.6/exe/bundle:20:in `<top (required)>'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/bin/bundle:25:in `load'
	from /Users/agrobbin/.asdf/installs/ruby/3.3.0/bin/bundle:25:in `<main>'

@vinistock
Copy link
Member

Oh, interesting. Do you mind adding some traces so that I can understand the sequence of LSP requests that are leading to this? After the associated PR, I can no longer reproduce this issue, so I'm having trouble understanding the root cause.

  1. Open the ruby-lsp's code for editing BUNDLE_GEMFILE=.ruby-lsp/Gemfile bundle open ruby-lsp
  2. Above this line, add
$stderr.puts("#{message[:method]} #{message.dig(:params, :textDocument, :uri)}")
  1. Below this line, add
$stderr.puts("#{method} #{uri}")

In essence, I'm trying to understand if, despite the mutex lock, we're still trying to process any feature requests for the untitled files before we process textDocument/didOpen. Which then means we probably can't put text synchronization notifications into the queue and need to process them straight away.

@vinistock vinistock reopened this Apr 10, 2024
@tgaff
Copy link

tgaff commented Apr 10, 2024

Also replicated in 0.16.3 with extension v0.5.17

I re-opened code with the following files from the previous session:

  • an erb file
  • an rb file
  • an erb file with some unsaved changes from the previous session
  • an unsaved scrap file in another window that code is detecting as ruby and that contains some valid ruby
2024-04-11 08:53:01.157 [info] (deno_ai) /Users/tgaff/.gem/ruby/3.2.3/gems/ruby-lsp-0.16.3/lib/ruby_lsp/store.rb:44:in `binread': no implicit conversion of nil into String (TypeError)

      set(uri: uri, source: File.binread(path), version: 0)
                                         ^^^^
	from /Users/tgaff/.gem/ruby/3.2.3/gems/ruby-lsp-0.16.3/lib/ruby_lsp/store.rb:44:in `get'
	from /Users/tgaff/.gem/ruby/3.2.3/gems/sorbet-runtime-0.5.11338/lib/types/private/methods/_methods.rb:279:in `bind_call'
	from /Users/tgaff/.gem/ruby/3.2.3/gems/sorbet-runtime-0.5.11338/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
	from /Users/tgaff/.gem/ruby/3.2.3/gems/ruby-lsp-0.16.3/lib/ruby_lsp/base_server.rb:55:in `block (2 levels) in start'
	from /Users/tgaff/.gem/ruby/3.2.3/gems/ruby-lsp-0.16.3/lib/ruby_lsp/base_server.rb:46:in `synchronize'
	from /Users/tgaff/.gem/ruby/3.2.3/gems/ruby-lsp-0.16.3/lib/ruby_lsp/base_server.rb:46:in `block in start'
	from /Users/tgaff/.gem/ruby/3.2.3/gems/language_server-protocol-3.17.0.3/lib/language_server/protocol/transport/io/reader.rb:20:in `read'
	from /Users/tgaff/.gem/ruby/3.2.3/gems/ruby-lsp-0.16.3/lib/ruby_lsp/base_server.rb:39:in `start'
	from /Users/tgaff/.gem/ruby/3.2.3/gems/sorbet-runtime-0.5.11338/lib/types/private/methods/_methods.rb:279:in `bind_call'
	from /Users/tgaff/.gem/ruby/3.2.3/gems/sorbet-runtime-0.5.11338/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
	from /Users/tgaff/.gem/ruby/3.2.3/gems/ruby-lsp-0.16.3/exe/ruby-lsp:89:in `<top (required)>'
	from /Users/tgaff/.gem/ruby/3.2.3/bin/ruby-lsp:25:in `load'
	from /Users/tgaff/.gem/ruby/3.2.3/bin/ruby-lsp:25:in `<top (required)>'
	from /Users/tgaff/.rubies/ruby-3.2.3/lib/ruby/3.2.0/bundler/cli/exec.rb:58:in `load'
	from /Users/tgaff/.rubies/ruby-3.2.3/lib/ruby/3.2.0/bundler/cli/exec.rb:58:in `kernel_load'
	from /Users/tgaff/.rubies/ruby-3.2.3/lib/ruby/3.2.0/bundler/cli/exec.rb:23:in `run'
	from /Users/tgaff/.rubies/ruby-3.2.3/lib/ruby/3.2.0/bundler/cli.rb:492:in `exec'
	from /Users/tgaff/.rubies/ruby-3.2.3/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /Users/tgaff/.rubies/ruby-3.2.3/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/tgaff/.rubies/ruby-3.2.3/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /Users/tgaff/.rubies/ruby-3.2.3/lib/ruby/3.2.0/bundler/cli.rb:34:in `dispatch'
	from /Users/tgaff/.rubies/ruby-3.2.3/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /Users/tgaff/.rubies/ruby-3.2.3/lib/ruby/3.2.0/bundler/cli.rb:28:in `start'
	from /Users/tgaff/.rubies/ruby-3.2.3/lib/ruby/gems/3.2.0/gems/bundler-2.4.19/libexec/bundle:37:in `block in <top (required)>'
	from /Users/tgaff/.rubies/ruby-3.2.3/lib/ruby/3.2.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from /Users/tgaff/.rubies/ruby-3.2.3/lib/ruby/gems/3.2.0/gems/bundler-2.4.19/libexec/bundle:29:in `<top (required)>'
	from /Users/tgaff/.rubies/ruby-3.2.3/bin/bundle:25:in `load'
	from /Users/tgaff/.rubies/ruby-3.2.3/bin/bundle:25:in `<main>'

@tgaff
Copy link

tgaff commented Apr 11, 2024

@vinstock I added the traces you suggested and I see:

2024-04-11 09:03:00.735 [info] (deno_ai) textDocument/didOpen untitled:Untitled-1

2024-04-11 09:03:00.735 [info] (deno_ai) textDocument/diagnostic untitled:Untitled-1
  1. I then closed the Untitled (and never-saved) file and restarted.
    a) I did not see the error in this case.
  2. Then I re-created that file (pasted same content) and restarted
    a) I couldn't reproduce the error either though.
  3. I then noticed the re-created version was detected as text. I changed it to ruby and restarted once more
    a) the crash returned

@agrobbin
Copy link

I can confirm that (3) is also the trigger for me, with an untitled file detected as Ruby causing the failure!

@mattboldt
Copy link

mattboldt commented Apr 11, 2024

Same scenario as @tgaff here -- I had some new, unsaved/untitled files open in tabs with valid ruby in them. After closing them and restarting LSP, it worked without errors.

@vinistock
Copy link
Member

I'm hoping the associated PR will fix it this time.

@stathis-alexander
Copy link

stathis-alexander commented May 3, 2024

EDIT: It appears I was on Ruby LSP Extension v0.6.10, a prerelease version. Ruby LSP is 16.6. I was able to resolve the issue by switching back to Ruby LSP Extension v0.5.21.

I am on ruby-lsp 16.6 and I am still receiving this error. It seems to occur anytime I have an unsaved ruby file open

2024-05-03 08:54:45.682 [info] (comptroller) /Users/alex.stathis/.gem/ruby/3.3.0/gems/ruby-lsp-0.16.6/lib/ruby_lsp/store.rb:44:in `binread': no implicit conversion of nil into String (TypeError)

      set(uri: uri, source: File.binread(path), version: 0)
                                         ^^^^
	from /Users/alex.stathis/.gem/ruby/3.3.0/gems/ruby-lsp-0.16.6/lib/ruby_lsp/store.rb:44:in `get'
	from /Users/alex.stathis/.gem/ruby/3.3.0/gems/ruby-lsp-0.16.6/lib/ruby_lsp/base_server.rb:55:in `block (2 levels) in start'
	from /Users/alex.stathis/.gem/ruby/3.3.0/gems/ruby-lsp-0.16.6/lib/ruby_lsp/base_server.rb:46:in `synchronize'
	from /Users/alex.stathis/.gem/ruby/3.3.0/gems/ruby-lsp-0.16.6/lib/ruby_lsp/base_server.rb:46:in `block in start'
	from /Users/alex.stathis/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/language_server-protocol-3.17.0.3/lib/language_server/protocol/transport/io/reader.rb:20:in `read'
	from /Users/alex.stathis/.gem/ruby/3.3.0/gems/ruby-lsp-0.16.6/lib/ruby_lsp/base_server.rb:39:in `start'
	from /Users/alex.stathis/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11346/lib/types/private/methods/_methods.rb:279:in `bind_call'
	from /Users/alex.stathis/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11346/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
	from /Users/alex.stathis/.gem/ruby/3.3.0/gems/ruby-lsp-0.16.6/exe/ruby-lsp:93:in `<top (required)>'
	from /Users/alex.stathis/.gem/ruby/3.3.0/bin/ruby-lsp:25:in `load'
	from /Users/alex.stathis/.gem/ruby/3.3.0/bin/ruby-lsp:25:in `<top (required)>'
	from /Users/alex.stathis/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.3.7/lib/bundler/cli/exec.rb:58:in `load'
	from /Users/alex.stathis/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.3.7/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /Users/alex.stathis/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.3.7/lib/bundler/cli/exec.rb:23:in `run'
	from /Users/alex.stathis/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.3.7/lib/bundler/cli.rb:484:in `exec'
	from /Users/alex.stathis/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.3.7/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /Users/alex.stathis/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.3.7/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/alex.stathis/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.3.7/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /Users/alex.stathis/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.3.7/lib/bundler/cli.rb:31:in `dispatch'
	from /Users/alex.stathis/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.3.7/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /Users/alex.stathis/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.3.7/lib/bundler/cli.rb:25:in `start'
	from /Users/alex.stathis/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.3.7/exe/bundle:48:in `block in <top (required)>'
	from /Users/alex.stathis/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.3.7/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
	from /Users/alex.stathis/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.3.7/exe/bundle:36:in `<top (required)>'
	from /Users/alex.stathis/.rbenv/versions/3.3.0/bin/bundle:25:in `load'
	from /Users/alex.stathis/.rbenv/versions/3.3.0/bin/bundle:25:in `<main>'

2024-05-03 08:54:45.688 [info] (comptroller) [Error - 8:54:45 AM] 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-05-03 08:54:45.689 [info] (comptroller) [Error - 8:54:45 AM] Request textDocument/diagnostic failed.
2024-05-03 08:54:45.689 [info] (comptroller) TypeError: Cannot read properties of undefined (reading 'errorClass')
    at ps.benchmarkMiddleware (/Users/alex.stathis/.vscode/extensions/shopify.ruby-lsp-0.6.10/out/extension.js:45:5666)
    at zu.pullAsync (/Users/alex.stathis/.vscode/extensions/shopify.ruby-lsp-0.6.10/out/extension.js:39:6422)

I can reproduce easily:

  1. open vscode, no unsaved files. ruby-lsp boots successfully
  2. cmd + n for a new tab, paste some ruby code in - ruby lsp crashes with the above error
  3. close unsaved file (don't save)
  4. cmd + shift + p -> ruby lsp start - ruby lsp boots

@peacefulseeker
Copy link

Same as what @stathis-alexander mentioned

The gem version in my case is 0.17.1 (v0.7.1 vscode plugin) with 3.3.1 ruby and asdf manager.:

/Users/avorobyov/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.1/lib/ruby_lsp/store.rb:44:in `binread': no implicit conversion of nil into String (TypeError)

Downgrading to v0.5.21 helped.

@vinistock , should the issue be reopened with more details given?

@vinistock
Copy link
Member

@peacefulseeker thank you for reporting. It's in fact a different regression and not the same issue as reported here. I opened a PR explaining and fixing it #2124.

@jesseduffield
Copy link

@vinistock I'm still getting this error on v0.17.4 (vscode extension v0.7.5). Also verified that it occurs after opening a new unsaved tab in vscode and setting the language to 'ruby'.

2024-07-02 13:59:57.519 [info] (api) Initializing Ruby LSP v0.17.4...

2024-07-02 13:59:57.576 [info] (api) Finished initializing Ruby LSP!

2024-07-02 13:59:57.641 [info] (api) Activating Ruby LSP Rails addon v0.3.7

2024-07-02 13:59:57.700 [info] (api) Ruby LSP Rails booting server

2024-07-02 13:59:59.267 [info] (api) /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/store.rb:44:in `binread': no implicit conversion of nil into String (TypeError)

      set(uri: uri, source: File.binread(path), version: 0)
                                         ^^^^
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/store.rb:44:in `get'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/base_server.rb:55:in `block (2 levels) in start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/base_server.rb:46:in `synchronize'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/base_server.rb:46:in `block in start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/language_server-protocol-3.17.0.3/lib/language_server/protocol/transport/io/reader.rb:20:in `read'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/base_server.rb:39:in `start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11463/lib/types/private/methods/_methods.rb:279:in `bind_call'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11463/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/exe/ruby-lsp:110:in `<top (required)>'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/ruby-lsp:25:in `load'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/ruby-lsp:25:in `<top (required)>'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli/exec.rb:58:in `load'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli/exec.rb:23:in `run'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli.rb:492:in `exec'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli.rb:34:in `dispatch'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli.rb:28:in `start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/exe/bundle:45:in `block in <top (required)>'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/exe/bundle:33:in `<top (required)>'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/bundle:25:in `load'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/bundle:25:in `<main>'

@andyw8
Copy link
Contributor

andyw8 commented Jul 2, 2024

👋 @jesseduffield

Also verified that it occurs after opening a new unsaved tab in vscode and setting the language to 'ruby'.

I can't seem to reproduce this, but perhaps I'm doing things in a slightly different way. Is it possible you could share a short video to demonstrate the exact steps?

@jesseduffield
Copy link

lsp-bug.mov

In this vid I:

  1. open vscode to a ruby project
  2. wait for ruby-lsp to start up
  3. click on an unsaved ruby file
  4. observe it enters a crash loop

Here's the logs up until the first couple errors:

2024-07-03 08:52:48.318 [info] (api) Running command: `rbenv exec ruby -W0 -rjson -e 'STDERR.print({env: ENV.to_h,yjit:!!defined?(RubyVM::YJIT),version:RUBY_VERSION}.to_json)'` in /Users/jesseduffieldduffield/repos/zenbu/app/api using shell: /bin/zsh
2024-07-03 08:52:48.320 [info] (api) Running command: `rbenv exec ruby -W0 -rjson -e 'STDERR.print({env: ENV.to_h,yjit:!!defined?(RubyVM::YJIT),version:RUBY_VERSION}.to_json)'` in /Users/jesseduffieldduffield/repos/zenbu/app/api using shell: /bin/zsh
2024-07-03 08:52:48.322 [info] (api) Running command: `rbenv exec ruby -W0 -rjson -e 'STDERR.print({env: ENV.to_h,yjit:!!defined?(RubyVM::YJIT),version:RUBY_VERSION}.to_json)'` in /Users/jesseduffieldduffield/repos/zenbu/app/api using shell: /bin/zsh
2024-07-03 08:52:48.324 [info] (api) Running command: `rbenv exec ruby -W0 -rjson -e 'STDERR.print({env: ENV.to_h,yjit:!!defined?(RubyVM::YJIT),version:RUBY_VERSION}.to_json)'` in /Users/jesseduffieldduffield/repos/zenbu/app/api using shell: /bin/zsh
2024-07-03 08:52:48.326 [info] (api) Running command: `rbenv exec ruby -W0 -rjson -e 'STDERR.print({env: ENV.to_h,yjit:!!defined?(RubyVM::YJIT),version:RUBY_VERSION}.to_json)'` in /Users/jesseduffieldduffield/repos/zenbu/app/api using shell: /bin/zsh
2024-07-03 08:52:48.328 [info] (api) Running command: `rbenv exec ruby -W0 -rjson -e 'STDERR.print({env: ENV.to_h,yjit:!!defined?(RubyVM::YJIT),version:RUBY_VERSION}.to_json)'` in /Users/jesseduffieldduffield/repos/zenbu/app/api using shell: /bin/zsh
2024-07-03 08:52:48.330 [info] (api) Running command: `rbenv exec ruby -W0 -rjson -e 'STDERR.print({env: ENV.to_h,yjit:!!defined?(RubyVM::YJIT),version:RUBY_VERSION}.to_json)'` in /Users/jesseduffieldduffield/repos/zenbu/app/api using shell: /bin/zsh
2024-07-03 08:52:48.332 [info] (api) Running command: `rbenv exec ruby -W0 -rjson -e 'STDERR.print({env: ENV.to_h,yjit:!!defined?(RubyVM::YJIT),version:RUBY_VERSION}.to_json)'` in /Users/jesseduffieldduffield/repos/zenbu/app/api using shell: /bin/zsh
2024-07-03 08:52:48.335 [info] (api) Running command: `rbenv exec ruby -W0 -rjson -e 'STDERR.print({env: ENV.to_h,yjit:!!defined?(RubyVM::YJIT),version:RUBY_VERSION}.to_json)'` in /Users/jesseduffieldduffield/repos/zenbu/app/api using shell: /bin/zsh
2024-07-03 08:52:49.973 [info] (api) Ruby LSP> Skipping custom bundle setup since /Users/jesseduffieldduffield/repos/zenbu/app/api/.ruby-lsp/Gemfile.lock already exists and is up to date

2024-07-03 08:52:49.982 [info] (api) Ruby LSP> Skipping custom bundle setup since /Users/jesseduffieldduffield/repos/zenbu/app/api/.ruby-lsp/Gemfile.lock already exists and is up to date

2024-07-03 08:52:49.982 [info] (api) Ruby LSP> Skipping custom bundle setup since /Users/jesseduffieldduffield/repos/zenbu/app/api/.ruby-lsp/Gemfile.lock already exists and is up to date

2024-07-03 08:52:49.990 [info] (api) Ruby LSP> Skipping custom bundle setup since /Users/jesseduffieldduffield/repos/zenbu/app/api/.ruby-lsp/Gemfile.lock already exists and is up to date

2024-07-03 08:52:49.992 [info] (api) Ruby LSP> Skipping custom bundle setup since /Users/jesseduffieldduffield/repos/zenbu/app/api/.ruby-lsp/Gemfile.lock already exists and is up to date

2024-07-03 08:52:50.001 [info] (api) Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle check || bundle install) 1>&2

2024-07-03 08:52:50.007 [info] (api) Ruby LSP> Skipping custom bundle setup since /Users/jesseduffieldduffield/repos/zenbu/app/api/.ruby-lsp/Gemfile.lock already exists and is up to date

2024-07-03 08:52:50.012 [info] (api) Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle check || bundle install) 1>&2

2024-07-03 08:52:50.013 [info] (api) Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle check || bundle install) 1>&2

2024-07-03 08:52:50.018 [info] (api) Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle check || bundle install) 1>&2

2024-07-03 08:52:50.018 [info] (api) Ruby LSP> Skipping custom bundle setup since /Users/jesseduffieldduffield/repos/zenbu/app/api/.ruby-lsp/Gemfile.lock already exists and is up to date

2024-07-03 08:52:50.019 [info] (api) Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle check || bundle install) 1>&2

2024-07-03 08:52:50.022 [info] (api) Ruby LSP> Skipping custom bundle setup since /Users/jesseduffieldduffield/repos/zenbu/app/api/.ruby-lsp/Gemfile.lock already exists and is up to date

2024-07-03 08:52:50.028 [info] (api) Ruby LSP> Skipping custom bundle setup since /Users/jesseduffieldduffield/repos/zenbu/app/api/.ruby-lsp/Gemfile.lock already exists and is up to date

2024-07-03 08:52:50.036 [info] (api) Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle check || bundle install) 1>&2

2024-07-03 08:52:50.055 [info] (api) Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle check || bundle install) 1>&2

2024-07-03 08:52:50.055 [info] (api) Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle check || bundle install) 1>&2

2024-07-03 08:52:50.058 [info] (api) Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle check || bundle install) 1>&2

2024-07-03 08:52:50.609 [info] (api) The Gemfile's dependencies are satisfied

2024-07-03 08:52:50.610 [info] (api) The Gemfile's dependencies are satisfied

2024-07-03 08:52:50.612 [info] (api) The Gemfile's dependencies are satisfied

2024-07-03 08:52:50.613 [info] (api) The Gemfile's dependencies are satisfied

2024-07-03 08:52:50.623 [info] (api) The Gemfile's dependencies are satisfied

2024-07-03 08:52:50.640 [info] (api) The Gemfile's dependencies are satisfied

2024-07-03 08:52:50.660 [info] (api) The Gemfile's dependencies are satisfied

2024-07-03 08:52:50.667 [info] (api) The Gemfile's dependencies are satisfied

2024-07-03 08:52:50.667 [info] (api) The Gemfile's dependencies are satisfied

2024-07-03 08:52:54.862 [info] (api) Initializing Ruby LSP v0.17.4...

2024-07-03 08:52:54.867 [info] (api) Initializing Ruby LSP v0.17.4...

2024-07-03 08:52:54.870 [info] (api) Initializing Ruby LSP v0.17.4...

2024-07-03 08:52:54.871 [info] (api) Initializing Ruby LSP v0.17.4...

2024-07-03 08:52:54.872 [info] (api) Initializing Ruby LSP v0.17.4...

2024-07-03 08:52:54.885 [info] (api) Initializing Ruby LSP v0.17.4...

2024-07-03 08:52:54.908 [info] (api) Initializing Ruby LSP v0.17.4...

2024-07-03 08:52:54.919 [info] (api) Initializing Ruby LSP v0.17.4...

2024-07-03 08:52:54.933 [info] (api) Initializing Ruby LSP v0.17.4...

2024-07-03 08:52:54.957 [info] (api) Finished initializing Ruby LSP!

2024-07-03 08:52:54.981 [info] (api) Finished initializing Ruby LSP!

2024-07-03 08:52:54.982 [info] (api) Finished initializing Ruby LSP!

2024-07-03 08:52:54.982 [info] (api) Finished initializing Ruby LSP!

2024-07-03 08:52:54.982 [info] (api) Finished initializing Ruby LSP!

2024-07-03 08:52:55.045 [info] (api) Finished initializing Ruby LSP!

2024-07-03 08:52:55.091 [info] (api) Finished initializing Ruby LSP!

2024-07-03 08:52:55.091 [info] (api) Finished initializing Ruby LSP!

2024-07-03 08:52:55.104 [info] (api) Finished initializing Ruby LSP!

2024-07-03 08:52:55.104 [info] (api) Activating Ruby LSP Rails addon v0.3.8

2024-07-03 08:52:55.134 [info] (api) Activating Ruby LSP Rails addon v0.3.8

2024-07-03 08:52:55.142 [info] (api) Activating Ruby LSP Rails addon v0.3.8

2024-07-03 08:52:55.144 [info] (api) Activating Ruby LSP Rails addon v0.3.8

2024-07-03 08:52:55.145 [info] (api) Activating Ruby LSP Rails addon v0.3.8

2024-07-03 08:52:55.180 [info] (api) Ruby LSP Rails booting server

2024-07-03 08:52:55.184 [info] (api) Activating Ruby LSP Rails addon v0.3.8

2024-07-03 08:52:55.206 [info] (api) Activating Ruby LSP Rails addon v0.3.8

2024-07-03 08:52:55.206 [info] (api) Activating Ruby LSP Rails addon v0.3.8

2024-07-03 08:52:55.221 [info] (api) Activating Ruby LSP Rails addon v0.3.8

2024-07-03 08:52:55.274 [info] (api) Ruby LSP Rails booting server

2024-07-03 08:52:55.275 [info] (api) Ruby LSP Rails booting server

2024-07-03 08:52:55.275 [info] (api) Ruby LSP Rails booting server

2024-07-03 08:52:55.282 [info] (api) Ruby LSP Rails booting server

2024-07-03 08:52:55.312 [info] (api) Ruby LSP Rails booting server

2024-07-03 08:52:55.337 [info] (api) Ruby LSP Rails booting server

2024-07-03 08:52:55.343 [info] (api) Ruby LSP Rails booting server

2024-07-03 08:52:55.370 [info] (api) Ruby LSP Rails booting server

2024-07-03 08:52:57.865 [info] (api) Finished booting Ruby LSP Rails server

2024-07-03 08:52:58.008 [info] (api) Finished booting Ruby LSP Rails server

2024-07-03 08:52:58.103 [info] (api) Finished booting Ruby LSP Rails server

2024-07-03 08:52:58.221 [info] (api) Finished booting Ruby LSP Rails server

2024-07-03 08:52:58.430 [info] (api) Finished booting Ruby LSP Rails server

2024-07-03 08:52:58.501 [info] (api) Finished booting Ruby LSP Rails server

2024-07-03 08:52:58.682 [info] (api) Finished booting Ruby LSP Rails server

2024-07-03 08:52:58.899 [info] (api) Finished booting Ruby LSP Rails server

2024-07-03 08:52:58.928 [info] (api) Finished booting Ruby LSP Rails server

2024-07-03 08:53:04.992 [info] (api) Ruby LSP Rails is force killing the server

2024-07-03 08:53:04.995 [info] (api) Ruby LSP Rails is force killing the server

2024-07-03 08:53:04.996 [info] (api) Ruby LSP Rails is force killing the server

2024-07-03 08:53:05.003 [info] (api) Ruby LSP Rails is force killing the server

2024-07-03 08:53:05.009 [info] (api) Ruby LSP Rails is force killing the server

2024-07-03 08:53:05.010 [info] (api) Ruby LSP Rails is force killing the server

2024-07-03 08:53:05.014 [info] (api) Ruby LSP Rails is force killing the server

2024-07-03 08:53:05.045 [info] (api) Ruby LSP Rails is force killing the server

2024-07-03 08:53:05.065 [info] (api) Ruby LSP Rails is force killing the server

2024-07-03 08:53:05.529 [info] (api) /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/store.rb:44:in `binread': no implicit conversion of nil into String (TypeError)

      set(uri: uri, source: File.binread(path), version: 0)
                                         ^^^^
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/store.rb:44:in `get'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/base_server.rb:55:in `block (2 levels) in start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/base_server.rb:46:in `synchronize'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/base_server.rb:46:in `block in start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/language_server-protocol-3.17.0.3/lib/language_server/protocol/transport/io/reader.rb:20:in `read'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/base_server.rb:39:in `start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11465/lib/types/private/methods/_methods.rb:279:in `bind_call'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11465/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/exe/ruby-lsp:110:in `<top (required)>'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/ruby-lsp:25:in `load'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/ruby-lsp:25:in `<top (required)>'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli/exec.rb:58:in `load'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli/exec.rb:23:in `run'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli.rb:492:in `exec'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli.rb:34:in `dispatch'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli.rb:28:in `start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/exe/bundle:45:in `block in <top (required)>'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/exe/bundle:33:in `<top (required)>'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/bundle:25:in `load'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/bundle:25:in `<main>'

2024-07-03 08:53:05.533 [info] (api) /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/store.rb:44:in `binread': no implicit conversion of nil into String (TypeError)

      set(uri: uri, source: File.binread(path), version: 0)
                                         ^^^^
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/store.rb:44:in `get'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/base_server.rb:55:in `block (2 levels) in start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/base_server.rb:46:in `synchronize'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/base_server.rb:46:in `block in start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/language_server-protocol-3.17.0.3/lib/language_server/protocol/transport/io/reader.rb:20:in `read'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/base_server.rb:39:in `start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11465/lib/types/private/methods/_methods.rb:279:in `bind_call'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11465/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/exe/ruby-lsp:110:in `<top (required)>'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/ruby-lsp:25:in `load'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/ruby-lsp:25:in `<top (required)>'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli/exec.rb:58:in `load'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli/exec.rb:23:in `run'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli.rb:492:in `exec'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli.rb:34:in `dispatch'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli.rb:28:in `start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/exe/bundle:45:in `block in <top (required)>'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/exe/bundle:33:in `<top (required)>'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/bundle:25:in `load'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/bundle:25:in `<main>'

2024-07-03 08:53:05.579 [info] (api) [Error - 08:53:05] Server process exited with code 1.
2024-07-03 08:53:05.584 [info] (api) [Info  - 08:53:05] Connection to server got closed. Server will restart.
2024-07-03 08:53:05.584 [info] (api) true
2024-07-03 08:53:05.588 [info] (api) [Error - 08:53:05] Server process exited with code 1.
2024-07-03 08:53:05.591 [info] (api) [Info  - 08:53:05] Connection to server got closed. Server will restart.
2024-07-03 08:53:05.591 [info] (api) true

@andyw8
Copy link
Contributor

andyw8 commented Jul 3, 2024

Thanks for that. It looks like this is a monorepo, containing 9 Rails apps? Are you able to reproduce on a simpler repo, e.g. with a single Rails app?

@andyw8
Copy link
Contributor

andyw8 commented Jul 3, 2024

Also, would you mind sharing the contents of your .code-workspace file? (feel free to anonymize it, I'm just interested in the structure).

@jesseduffield
Copy link

jesseduffield commented Jul 5, 2024

Yes, I'm in a code workspace for a monorepo, though there's only one folder in the repo that's for rails:

Here's the code-workspace file (the api path is rails):

{
	"folders": [
		{
			"path": "."
		},
		{
			"path": "api"
		},
		{
			"path": "pulumi"
		},
		{
			"path": "frontend"
		},
		{
			"path": "ops"
		}
	],
	"settings": {
		"typescript.tsdk": "frontend/node_modules/typescript/lib",
	}
}

Also, my vscode settings file (so that we don't see the same folder shown twice):

{
  "files.exclude": {
    "api": true,
    "pulumi": true,
    "frontend": true,
    "ops": true
  }
}

Some more investigation I did:

  • if I directly open the api folder outside of a workspace, I get no duplicate logs and no crash when focusing an unsaved ruby file
  • if I comment out the "." path in the codespace and reload, I also get no duplicate logs and no crash. But this is not ideal: I want to see root files like README.md
  • if I comment out each path except for "." (effectively making this a regular workspace but where the rails code is in a child folder), I get duplicate logs and it does crash on an unsaved ruby file.

@andyw8
Copy link
Contributor

andyw8 commented Jul 5, 2024

Thanks. Could you try adding a name attribute to each entry in folders, e.g.:

                {
			"path": "."
                        "name": "root",
		},
		{
			"path": "api"
                        "name": "api",
		},
...

and record another video of the output during boot.

@jesseduffield
Copy link

jesseduffield commented Jul 6, 2024

Seems like with that it's only showing one set of logs so that's good. But alas it still crashes. I also noticed that if I just open vscode directly to a ruby file, the lsp doesn't actually start until I go to another ruby file (shown in recording).

lsp-bug-2.mov

Logs up to the first error:

2024-07-06 13:15:16.165 [info] (api) Running command: `rbenv exec ruby -W0 -rjson -e 'STDERR.print({env: ENV.to_h,yjit:!!defined?(RubyVM::YJIT),version:RUBY_VERSION}.to_json)'` in /Users/jesseduffieldduffield/repos/zenbu/app/api using shell: /bin/zsh
2024-07-06 13:15:17.755 [info] (api) Ruby LSP> Skipping custom bundle setup since /Users/jesseduffieldduffield/repos/zenbu/app/api/.ruby-lsp/Gemfile.lock already exists and is up to date

2024-07-06 13:15:17.776 [info] (api) Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle check || bundle install) 1>&2

2024-07-06 13:15:18.244 [info] (api) The Gemfile's dependencies are satisfied

2024-07-06 13:15:21.909 [info] (api) Initializing Ruby LSP v0.17.4...

2024-07-06 13:15:21.986 [info] (api) Finished initializing Ruby LSP!

2024-07-06 13:15:22.045 [info] (api) Activating Ruby LSP Rails addon v0.3.8

2024-07-06 13:15:22.122 [info] (api) Ruby LSP Rails booting server

2024-07-06 13:15:28.632 [info] (api) /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/store.rb:44:in `binread': no implicit conversion of nil into String (TypeError)

      set(uri: uri, source: File.binread(path), version: 0)
                                         ^^^^
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/store.rb:44:in `get'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/base_server.rb:55:in `block (2 levels) in start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/base_server.rb:46:in `synchronize'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/base_server.rb:46:in `block in start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/language_server-protocol-3.17.0.3/lib/language_server/protocol/transport/io/reader.rb:20:in `read'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/lib/ruby_lsp/base_server.rb:39:in `start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11471/lib/types/private/methods/_methods.rb:279:in `bind_call'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11471/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.4/exe/ruby-lsp:110:in `<top (required)>'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/ruby-lsp:25:in `load'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/ruby-lsp:25:in `<top (required)>'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli/exec.rb:58:in `load'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli/exec.rb:23:in `run'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli.rb:492:in `exec'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli.rb:34:in `dispatch'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli.rb:28:in `start'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/exe/bundle:45:in `block in <top (required)>'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/exe/bundle:33:in `<top (required)>'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/bundle:25:in `load'
	from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/bundle:25:in `<main>'

@vinistock
Copy link
Member

@jesseduffield thank you so much for all of the help diagnosing this.

This #2268 should fix it.

@jesseduffield
Copy link

Thanks @vinistock . I'm not sure how to go about testing that: will that appear in a pre-release version soon?

@vinistock
Copy link
Member

I just cut v0.7.10 stable, which includes the fix. Please let us know if the issue has been fixed!

@jesseduffield
Copy link

Thanks: I've tested with that and I'm no longer getting crashes when I focus an unsaved ruby file. However, I'm now getting an error during the indexing phase:

image

This error occurs regardless of whether I have any unsaved ruby files open in the editor. I'm not seeing anything in the logs relating to it:

2024-07-10 09:53:03.296 [info] (api) Shutting down Ruby LSP...

2024-07-10 09:53:03.297 [info] (api) Ruby LSP Rails shutting down server

2024-07-10 09:53:21.141 [info] (api) Running command: `rbenv exec ruby -W0 -rjson -e 'STDERR.print({env: ENV.to_h,yjit:!!defined?(RubyVM::YJIT),version:RUBY_VERSION}.to_json)'` in /Users/jesseduffieldduffield/repos/zenbu/app/api using shell: /bin/zsh
2024-07-10 09:53:22.444 [info] (api) Ruby LSP> Skipping custom bundle setup since /Users/jesseduffieldduffield/repos/zenbu/app/api/.ruby-lsp/Gemfile.lock already exists and is up to date

2024-07-10 09:53:22.459 [info] (api) Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle check || bundle install) 1>&2

2024-07-10 09:53:22.952 [info] (api) The Gemfile's dependencies are satisfied

2024-07-10 09:53:26.740 [info] (api) Initializing Ruby LSP v0.17.5...

2024-07-10 09:53:26.810 [info] (api) Finished initializing Ruby LSP!

2024-07-10 09:53:26.852 [info] (api) Activating Ruby LSP Rails addon v0.3.8

2024-07-10 09:53:26.897 [info] (api) Ruby LSP Rails booting server

2024-07-10 09:53:33.411 [info] (api) Finished booting Ruby LSP Rails server

Also a separate issue that was already present: If I open vscode to a ruby file, ruby-lsp does not start until I focus a different ruby file (either via clicking on another tab or clicking in the file explorer). I'm happy to raise a separate issue for that if need be.

@vinistock
Copy link
Member

Thanks for reporting back. For the indexing error, can you please run BUNDLE_GEMFILE=.ruby-lsp/Gemfile bundle exec ruby-lsp-doctor, check which file it fails on and then provide us with the general structure that causes indexing to fail? You don't have to include the code exactly as is and we only care about declarations of classes, modules, methods and instance variables. As long as we understand the pattern that triggers the error, we can fix it.

Regarding your second point, the lazy activation itself is intentional. We received reports of users with over 20 Ruby workspaces and trying to eagerly activate would max out their CPU while indexing all of them and explode in memory usage. We currently register lazy activation on 3 events: the active editor changed (when you switch files), when a Ruby file is opened or when you change the workspaces included in the current window.

I guess we could also check for the files that are currently opened and if any of them are Ruby files, we can already activate.

I'll take a look at this second one, it should be fairly easy to achieve. Please report back if you figure out which code pattern fails indexing.

@jesseduffield
Copy link

When I run that lsp-doctor command it fails on a gem:

indexing: /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/httplog-1.6.3/lib/httplog/adapters/http.rb
/Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11478/lib/types/_types.rb:222:in `must': Passed `nil` into T.must (TypeError)

      raise TypeError.new("Passed `nil` into T.must")
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.6/lib/ruby_indexer/lib/ruby_indexer/index.rb:523:in `existing_or_new_singleton_class'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11478/lib/types/private/methods/call_validation_2_7.rb:108:in `bind_call'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11478/lib/types/private/methods/call_validation_2_7.rb:108:in `block in create_validator_method_fast1'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.6/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb:413:in `handle_instance_variable'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11478/lib/types/private/methods/call_validation_2_7.rb:1594:in `bind_call'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11478/lib/types/private/methods/call_validation_2_7.rb:1594:in `block in create_validator_procedure_medium2'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.6/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb:351:in `on_instance_variable_write_node_enter'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11478/lib/types/private/methods/call_validation_2_7.rb:687:in `bind_call'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11478/lib/types/private/methods/call_validation_2_7.rb:687:in `block in create_validator_procedure_fast1'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/dispatcher.rb:712:in `block in visit_instance_variable_write_node'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/dispatcher.rb:712:in `each'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/dispatcher.rb:712:in `visit_instance_variable_write_node'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/node.rb:10412:in `accept'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `each'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/dispatcher.rb:1185:in `visit_statements_node'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/node.rb:17459:in `accept'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `each'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/dispatcher.rb:177:in `visit_block_node'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/node.rb:1758:in `accept'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `each'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/dispatcher.rb:217:in `visit_call_node'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/node.rb:2478:in `accept'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `each'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/dispatcher.rb:849:in `visit_local_variable_write_node'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/node.rb:12525:in `accept'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `each'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/dispatcher.rb:1185:in `visit_statements_node'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/node.rb:17459:in `accept'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `each'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/dispatcher.rb:177:in `visit_block_node'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/node.rb:1758:in `accept'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `each'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/dispatcher.rb:217:in `visit_call_node'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/node.rb:2478:in `accept'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `each'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/dispatcher.rb:1185:in `visit_statements_node'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/node.rb:17459:in `accept'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `each'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/dispatcher.rb:273:in `visit_class_node'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/node.rb:3606:in `accept'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `each'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/dispatcher.rb:1185:in `visit_statements_node'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/node.rb:17459:in `accept'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `each'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/dispatcher.rb:897:in `visit_module_node'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/node.rb:13258:in `accept'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `each'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/dispatcher.rb:1185:in `visit_statements_node'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/node.rb:17459:in `accept'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `each'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/dispatcher.rb:601:in `visit_if_node'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/node.rb:8508:in `accept'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `each'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/dispatcher.rb:1185:in `visit_statements_node'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/node.rb:17459:in `accept'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `each'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:31:in `visit_child_nodes'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/dispatcher.rb:1033:in `visit_program_node'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/node.rb:15301:in `accept'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/prism-0.30.0/lib/prism/visitor.rb:19:in `visit'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.6/lib/ruby_indexer/lib/ruby_indexer/index.rb:271:in `index_single'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11478/lib/types/private/methods/call_validation.rb:167:in `bind_call'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11478/lib/types/private/methods/call_validation.rb:167:in `validate_call_skip_block_type'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11478/lib/types/private/methods/call_validation.rb:109:in `block in create_validator_slow_skip_block_type'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.6/exe/ruby-lsp-doctor:22:in `block in <top (required)>'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.6/exe/ruby-lsp-doctor:20:in `each'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.17.6/exe/ruby-lsp-doctor:20:in `<top (required)>'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/ruby-lsp-doctor:25:in `load'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/ruby-lsp-doctor:25:in `<top (required)>'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli/exec.rb:58:in `load'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli/exec.rb:58:in `kernel_load'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli/exec.rb:23:in `run'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli.rb:492:in `exec'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli.rb:34:in `dispatch'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/cli.rb:28:in `start'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/exe/bundle:45:in `block in <top (required)>'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/bundler-2.4.10/exe/bundle:33:in `<top (required)>'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/bundle:25:in `load'
        from /Users/jesseduffieldduffield/.rbenv/versions/3.3.3/bin/bundle:25:in `<main>'

Here's the file in github: https://github.com/trusche/httplog/blob/master/lib/httplog/adapters/http.rb

@andyw8
Copy link
Contributor

andyw8 commented Jul 11, 2024

Thank you, I've opened an issue for that: #2287

@andyw8
Copy link
Contributor

andyw8 commented Jul 11, 2024

Until it's fixed, you can exclude that gem from indexing: https://github.com/Shopify/ruby-lsp?tab=readme-ov-file#configuring-code-indexing

@jesseduffield
Copy link

Thanks, will do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet