Shopify / ruby-lsp

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

Getting error on formatting <NoMethodError: undefined method `anything' for T:Module> #1657

Closed MehtabRiaz closed 7 months ago

MehtabRiaz commented 7 months ago

Operating System

Ubuntu 23.10

Ruby version

3.2.0

Project has a bundle

Ruby version manager being used

rbenv

Description

Please note the following information regarding a persistent error in multiple versions of a program: 0.6.10, 0.5.11, and 0.3.6. In order to reproduce the issue, follow these steps:

  1. Install one of the versions mentioned above.
  2. Open any .rb file and attempt to format it using the following config:

"rubyLsp.formatter": "rubocop", "rubyLsp.rubyVersionManager": "rbenv", "rubyLsp.yjit": true, "[ruby]": { "editor.defaultFormatter": "Shopify.ruby-lsp", "editor.formatOnSave": true, "editor.formatOnType": true, "editor.tabSize": 2, "editor.insertSpaces": true, "editor.semanticHighlighting.enabled": true, "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, "files.trimFinalNewlines": true, "editor.rulers": [120] }

  1. You will see an error notification, and the developer console will display the error as well.
  2. The error persists in the following location: ".../.vscode/extensions/shopify.ruby-lsp-0.3.6/out/extension.js:4:228"
vinistock commented 7 months ago

Thank you for the bug report!

This same bug has been reported a few times https://github.com/Shopify/ruby-lsp/issues/1342, https://github.com/Shopify/ruby-lsp/issues/1322, https://github.com/Shopify/ruby-lsp/issues/1672.

The issue has been fixed for a while now. Please, ensure that

mehtab-riaz commented 7 months ago

Thanks it worked.

dmccraw commented 7 months ago

We were seeing this issue because our ruby project's dependencies were using an old version of sorbet-runtime. I wonder if a specific version of sorbet-runtime should be required as part of the .ruby-lsp/Gemfile?

vinistock commented 7 months ago

We try to minimize the dependencies inserted in .ruby-lsp/Gemfile exactly to avoid conflicts with the main Gemfile.

This situation is a bit of an odd one because we ended up using a newer sorbet-runtime feature that was not available in older versions, but I would vote against adding more entries in .ruby-lsp/Gemfile.