-
Notifications
You must be signed in to change notification settings - Fork 172
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
Comments
Also seeing this exact error and unable to start server. chruby, ruby 3.2.3, OSX-intel |
Following - I am getting an identical error with |
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? |
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 :) |
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. |
We need to first understand what situation causes the URI's path to be Maybe this only happens for files in the For the others that have replied here, are you on the latest version of both the extension and server? |
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. |
@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. |
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. |
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: |
Thanks for all the information. The associated PR should fix this issue. |
Thanks @vinistock! Will try it as soon as it's released and report back. |
Just in case anyone else also has the same issue after updating Thank you @vinistock for the quick fix here! |
@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>' |
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.
$stderr.puts("#{message[:method]} #{message.dig(:params, :textDocument, :uri)}")
$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 |
Also replicated in 0.16.3 with extension v0.5.17 I re-opened code with the following files from the previous session:
|
@vinstock I added the traces you suggested and I see:
|
I can confirm that (3) is also the trigger for me, with an untitled file detected as Ruby causing the failure! |
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. |
I'm hoping the associated PR will fix it this time. |
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
I can reproduce easily:
|
Same as what @stathis-alexander mentioned The gem version in my case is
Downgrading to @vinistock , should the issue be reopened with more details given? |
@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. |
@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'.
|
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? |
lsp-bug.movIn this vid I:
Here's the logs up until the first couple errors:
|
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? |
Also, would you mind sharing the contents of your |
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:
|
Thanks. Could you try adding a
and record another video of the output during boot. |
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.movLogs up to the first error:
|
@jesseduffield thank you so much for all of the help diagnosing this. This #2268 should fix it. |
Thanks @vinistock . I'm not sure how to go about testing that: will that appear in a pre-release version soon? |
I just cut v0.7.10 stable, which includes the fix. Please let us know if the issue has been fixed! |
Thanks for reporting back. For the indexing error, can you please run 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. |
When I run that lsp-doctor command it fails on a gem:
Here's the file in github: https://github.com/trusche/httplog/blob/master/lib/httplog/adapters/http.rb |
Thank you, I've opened an issue for that: #2287 |
Until it's fixed, you can exclude that gem from indexing: https://github.com/Shopify/ruby-lsp?tab=readme-ov-file#configuring-code-indexing |
Thanks, will do |
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?
The text was updated successfully, but these errors were encountered: