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

Hidden dependency on rubocop in ruby-lsp 0.18.2 #2604

Closed
thedanbob opened this issue Sep 23, 2024 · 2 comments · Fixed by #2609 or #2610
Closed

Hidden dependency on rubocop in ruby-lsp 0.18.2 #2604

thedanbob opened this issue Sep 23, 2024 · 2 comments · Fixed by #2609 or #2610
Labels
bug Something isn't working help-wanted Extra attention is needed non-vscode

Comments

@thedanbob
Copy link

Description

Reproduction steps

Start Ruby LSP in a Rails project that isn't using Rubocop.

Error message

Ruby LSP> Skipping custom bundle setup since /home/dan/<snip>/.ruby-lsp/Gemfile.lock already exists and is up to date
Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle check || bundle install) 1>&2
The following gems are missing
 * ruby-lsp (0.18.2)
 * debug (1.9.2)
 * ruby-lsp-rails (0.3.16)
 * language_server-protocol (3.17.0.3)
 * prism (1.0.0)
 * rbs (3.5.3)
 * sorbet-runtime (0.5.11577)
Install missing gems with `bundle install`
Fetching gem metadata from https://rubygems.org/.........
Fetching language_server-protocol 3.17.0.3
Fetching rbs 3.5.3
Fetching sorbet-runtime 0.5.11577
Fetching prism 1.0.0
Fetching debug 1.9.2
Installing language_server-protocol 3.17.0.3
Installing rbs 3.5.3 with native extensions
Installing prism 1.0.0 with native extensions
Installing sorbet-runtime 0.5.11577
Installing debug 1.9.2 with native extensions
Fetching ruby-lsp 0.18.2
Installing ruby-lsp 0.18.2
Fetching ruby-lsp-rails 0.3.16
Installing ruby-lsp-rails 0.3.16
Bundle complete! 21 Gemfile dependencies, 89 gems now installed.
Bundled gems are installed into `./vendor/bundle`
Removing bundler (2.5.16)
 /home/dan/<snip>/vendor/bundle/ruby/3.3.0/gems/ruby-lsp-0.18.2/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb:34:in `block in <class:RuboCopDiagnostic>': uninitialized constant RubyLsp::Requests::Support::RuboCopDiagnostic::RuboCop (NameError)

        sig { params(document: RubyDocument, offense: RuboCop::Cop::Offense, uri: URI::Generic).void }
                                                      ^^^^^^^
        from  /home/dan/<snip>/vendor/bundle/ruby/3.3.0/gems/sorbet-runtime-0.5.11577/lib/types/private/methods/_methods.rb:360:in `instance_exec'
        from  /home/dan/<snip>/vendor/bundle/ruby/3.3.0/gems/sorbet-runtime-0.5.11577/lib/types/private/methods/_methods.rb:360:in `run_builder'
        from  /home/dan/<snip>/vendor/bundle/ruby/3.3.0/gems/sorbet-runtime-0.5.11577/lib/types/private/methods/_methods.rb:338:in `run_sig'
        from  /home/dan/<snip>/vendor/bundle/ruby/3.3.0/gems/sorbet-runtime-0.5.11577/lib/types/private/methods/_methods.rb:248:in `block in _on_method_added'
        from  /home/dan/<snip>/vendor/bundle/ruby/3.3.0/gems/sorbet-runtime-0.5.11577/lib/types/private/methods/_methods.rb:449:in `run_sig_block_for_key'
        from  /home/dan/<snip>/vendor/bundle/ruby/3.3.0/gems/sorbet-runtime-0.5.11577/lib/types/private/methods/_methods.rb:469:in `block in run_all_sig_blocks'
        from <internal:kernel>:187:in `loop'
        from  /home/dan/<snip>/vendor/bundle/ruby/3.3.0/gems/sorbet-runtime-0.5.11577/lib/types/private/methods/_methods.rb:466:in `run_all_sig_blocks'
        from  /home/dan/<snip>/vendor/bundle/ruby/3.3.0/gems/sorbet-runtime-0.5.11577/lib/types/utils.rb:85:in `run_all_sig_blocks'
        from  /home/dan/<snip>/vendor/bundle/ruby/3.3.0/gems/ruby-lsp-0.18.2/exe/ruby-lsp:74:in `<top (required)>'
        from  /home/dan/<snip>/vendor/bundle/ruby/3.3.0/bin/ruby-lsp:25:in `load'
        from  /home/dan/<snip>/vendor/bundle/ruby/3.3.0/bin/ruby-lsp:25:in `<top (required)>'
        from /home/dan/.rbenv/versions/3.3.5/lib/ruby/3.3.0/bundler/cli/exec.rb:58:in `load'
        from /home/dan/.rbenv/versions/3.3.5/lib/ruby/3.3.0/bundler/cli/exec.rb:58:in `kernel_load'
        from /home/dan/.rbenv/versions/3.3.5/lib/ruby/3.3.0/bundler/cli/exec.rb:23:in `run'
        from /home/dan/.rbenv/versions/3.3.5/lib/ruby/3.3.0/bundler/cli.rb:455:in `exec'
        from /home/dan/.rbenv/versions/3.3.5/lib/ruby/3.3.0/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
        from /home/dan/.rbenv/versions/3.3.5/lib/ruby/3.3.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        from /home/dan/.rbenv/versions/3.3.5/lib/ruby/3.3.0/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
        from /home/dan/.rbenv/versions/3.3.5/lib/ruby/3.3.0/bundler/cli.rb:35:in `dispatch'
        from /home/dan/.rbenv/versions/3.3.5/lib/ruby/3.3.0/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
        from /home/dan/.rbenv/versions/3.3.5/lib/ruby/3.3.0/bundler/cli.rb:29:in `start'
        from /home/dan/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.16/exe/bundle:28:in `block in <top (required)>'
        from /home/dan/.rbenv/versions/3.3.5/lib/ruby/3.3.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
        from /home/dan/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.16/exe/bundle:20:in `<top (required)>'
        from /home/dan/.rbenv/versions/3.3/bin/bundle:25:in `load'
        from /home/dan/.rbenv/versions/3.3/bin/bundle:25:in `<main>'

Workaround

Add rubocop to the Gemfile.

I suspect the issue was introduced here: 5ed8b91

@thedanbob thedanbob added bug Something isn't working help-wanted Extra attention is needed non-vscode labels Sep 23, 2024
@theodoretliu
Copy link

Also seeing the same issue today! Proposed a very simple fix but there might be a more principled one. Happy to adopt a better solution :)

Earlopain added a commit to Earlopain/ruby-lsp that referenced this issue Sep 24, 2024
Closes Shopify#2604
Alternative to Shopify#2605

This moves the two command CI checks into the test suite.
They would have cought this error, _expect_ rubocop is available to these.
So, create a seperate Gemfile that contains only the gem itself.
Earlopain added a commit to Earlopain/ruby-lsp that referenced this issue Sep 24, 2024
Closes Shopify#2604
Alternative to Shopify#2605

This moves the two command CI checks into the test suite.
They would have cought this error, _expect_ rubocop is available to these.
So, create a seperate Gemfile that contains only the gem itself.

Co-authored-by: Theodore Liu <[email protected]>
Earlopain added a commit to Earlopain/ruby-lsp that referenced this issue Sep 24, 2024
Closes Shopify#2604
Alternative to Shopify#2605

This moves the two command CI checks into the test suite.
They would have cought this error, _expect_ rubocop is available to these.
So, create a seperate Gemfile that contains only the gem itself.

Co-authored-by: Theodore Liu <[email protected]>
@vinistock
Copy link
Member

Okay, we just released v0.18.3 with the fix. Here's how to force update:

VS Code

  • CMD/CTRL + SHIFT + P (open the command palette)
  • Search and run Ruby LSP: Update language server gem

Non VS Code

BUNDLE_GEMFILE=.ruby-lsp/Gemfile bundle update ruby-lsp

Earlopain added a commit to Earlopain/ruby-lsp that referenced this issue Sep 24, 2024
The CI commands use the Gemfile of the repo, which contains
additional gems like `rubocop` and `syntax_tree`.

This hides issues like Shopify#2604. So, create a separate Gemfile
containing only ruby-lsp and use that instead
vinistock pushed a commit that referenced this issue Sep 30, 2024
The CI commands use the Gemfile of the repo, which contains
additional gems like `rubocop` and `syntax_tree`.

This hides issues like #2604. So, create a separate Gemfile
containing only ruby-lsp and use that instead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help-wanted Extra attention is needed non-vscode
Projects
None yet
3 participants