Skip to content

ruby-lsp diagnostics crash with RuboCop 1.84.1: undefined method 'source_buffer' for PseudoSourceRange #3941

@mioruggieroguida

Description

@mioruggieroguida

Description

Ruby LSP Information

VS Code Version

1.109.0

Ruby LSP Extension Version

0.10.0

Ruby LSP Server Version

0.26.5

Ruby LSP Add-ons

  • RuboCop (1.84.1)

Ruby Version

3.2.2

Ruby Version Manager

none

Installed Extensions

Click to expand
  • black-formatter (2025.2.0)
  • copilot-chat (0.37.1)
  • cpptools (1.30.4)
  • debugpy (2025.18.0)
  • gitlens (17.9.0)
  • python (2026.0.0)
  • remote-explorer (0.5.0)
  • remote-ssh (0.122.0)
  • remote-ssh-edit (0.87.0)
  • ruby-lsp (0.10.0)
  • vscode-byebug (0.1.2)
  • vscode-openfoam (0.0.6)
  • vscode-pylance (2025.12.102)
  • vscode-rdbg (0.2.2)

Ruby LSP Settings

Click to expand
Workspace
{}
User
{
  "enabledFeatures": {
    "codeActions": true,
    "diagnostics": true,
    "documentHighlights": true,
    "documentLink": true,
    "documentSymbols": true,
    "foldingRanges": true,
    "formatting": true,
    "hover": true,
    "inlayHint": true,
    "onTypeFormatting": true,
    "selectionRanges": true,
    "semanticHighlighting": true,
    "completion": true,
    "codeLens": true,
    "definition": true,
    "workspaceSymbol": true,
    "signatureHelp": true,
    "typeHierarchy": true
  },
  "featuresConfiguration": {},
  "addonSettings": {},
  "rubyVersionManager": {
    "identifier": "auto"
  },
  "customRubyCommand": "",
  "formatter": "auto",
  "linters": null,
  "bundleGemfile": "",
  "testTimeout": 30,
  "branch": "",
  "pullDiagnosticsOn": "both",
  "useBundlerCompose": false,
  "bypassTypechecker": false,
  "rubyExecutablePath": "",
  "indexing": {},
  "erbSupport": true,
  "featureFlags": {},
  "sigOpacityLevel": "1"
}

Reproduction steps

I am not able to reproduce consistently, but it happens occasionally. I could not identify when exactly

I receive this error in the vscode bottom right section

Error running diagnostics: undefined method `source_buffer' for #<struct RuboCop::Cop::Offense::PseudoSourceRange line=1, column=0, source_line="", begin_pos=0, end_pos=0>

This is what the output pane reports

2026-02-06 07:04:25.940 [info] (MCTools) [RuboCop] Initialized RuboCop LSP addon 1.84.1.

2026-02-06 07:04:26.079 [info] (MCTools) [Error - 07:04:26] Diagnostics failed with
: /Users/ruggiero/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.84.1/lib/rubocop/cop/offense.rb:142:in `highlighted_area': undefined method `source_buffer' for #<struct RuboCop::Cop::Offense::PseudoSourceRange line=1, column=0, source_line="", begin_pos=0, end_pos=0> (NoMethodError)

        source_buffer = Parser::Source::Buffer.new(location.source_buffer.name, source: source_line)
                                                           ^^^^^^^^^^^^^^
Did you mean?  source_line
	from /Users/ruggiero/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-0.26.5/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb:47:in `to_lsp_diagnostic'
	from /Users/ruggiero/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-0.26.5/lib/ruby_lsp/requests/support/rubocop_formatter.rb:50:in `block in run_diagnostic'
	from /Users/ruggiero/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-0.26.5/lib/ruby_lsp/requests/support/rubocop_formatter.rb:45:in `map'
	from /Users/ruggiero/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-0.26.5/lib/ruby_lsp/requests/support/rubocop_formatter.rb:45:in `run_diagnostic'
	from /Users/ruggiero/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-0.26.5/lib/ruby_lsp/requests/diagnostics.rb:41:in `block in perform'
	from /Users/ruggiero/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-0.26.5/lib/ruby_lsp/requests/diagnostics.rb:40:in `each'
	from /Users/ruggiero/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-0.26.5/lib/ruby_lsp/requests/diagnostics.rb:40:in `perform'
	from /Users/ruggiero/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-0.26.5/lib/ruby_lsp/server.rb:888:in `block in text_document_diagnostic'
	from /Users/ruggiero/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-0.26.5/lib/ruby_lsp/document.rb:72:in `cache_fetch'
	from /Users/ruggiero/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-0.26.5/lib/ruby_lsp/server.rb:885:in `text_document_diagnostic'
	from /Users/ruggiero/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-0.26.5/lib/ruby_lsp/server.rb:62:in `process_message'
	from /Users/ruggiero/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-0.26.5/lib/ruby_lsp/base_server.rb:179:in `handle_incoming_message'
	from /Users/ruggiero/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-0.26.5/lib/ruby_lsp/base_server.rb:157:in `block in new_worker'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions