Skip to content

VSCode LSP formatter crashes #14475

@Rylan12

Description

@Rylan12

Hi there, I'm one of the maintainers of Homebrew, and we're running into a RuboCop/Ruby LSP issue in our Homebrew/brew repository. When formatting a document with correctable RuboCop violations, the formatting fails with a message like this (full log is below):

An internal error occurred for the Layout/IndentationWidth cop. (RubyLsp::Requests::Support::InternalRuboCopError)
Updating to a newer version of RuboCop may solve this.
For more details, run RuboCop on the command line.

I reported this initially to the Ruby LSP in Shopify/ruby-lsp#3723, but since it's only a problem when using the rubocop formatter and not rubocop_internal, it sounds like it's actually a Ruby LSP addon issue.

Unfortunately, I can't seem to reproduce the issue when running rubocop manually on the command line, or outside of VSCode.

When reporting to Ruby LSP, I was told the issue is related to "reusing the existing Prism parse result to avoid double parsing", and there are a handful of other issues that are related (Shopify/ruby-lsp#3665, Shopify/ruby-lsp#3657).


Expected behavior

Formatting the document should behave as expected

Actual behavior

Here are the logs from VSCode. I'm happy to provide any additional information I can.

2025-08-23 00:35:16.872 [info] (homebrew) Determined that document should be indexed: file:///opt/homebrew/Library/Homebrew/formula.rb
2025-08-23 00:35:22.052 [info] (homebrew) [Error - 12:35:22 AM] Formatting failed with
: /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/lsp/stdin_runner.rb:67:in 'RuboCop::Lsp::StdinRunner#run': An internal error occurred for the Layout/IndentationWidth cop. (RubyLsp::Requests::Support::InternalRuboCopError)
Updating to a newer version of RuboCop may solve this.
For more details, run RuboCop on the command line.

	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/lsp/runtime.rb:43:in 'RuboCop::LSP::Runtime#format'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/ruby_lsp/rubocop/runtime_adapter.rb:28:in 'RubyLsp::RuboCop::RuntimeAdapter#run_formatting'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/ruby-lsp-0.26.1/lib/ruby_lsp/requests/formatting.rb:35:in 'RubyLsp::Requests::Formatting#perform'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/ruby-lsp-0.26.1/lib/ruby_lsp/server.rb:648:in 'RubyLsp::Server#text_document_formatting'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/ruby-lsp-0.26.1/lib/ruby_lsp/server.rb:46:in 'RubyLsp::Server#process_message'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/ruby-lsp-0.26.1/lib/ruby_lsp/base_server.rb:168:in 'block in RubyLsp::BaseServer#new_worker'
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:176:in 'RuboCop::Cop::Commissioner#with_cop_error_handling': cause: #<NoMethodError: undefined method 'else' for an instance of Parser::Source::Map::Keyword> (RuboCop::ErrorWithAnalyzedFileLocation)
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:106:in 'block in RuboCop::Cop::Commissioner#trigger_responding_cops'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:105:in 'Array#each'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:105:in 'RuboCop::Cop::Commissioner#trigger_responding_cops'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:69:in 'RuboCop::Cop::Commissioner#on_if'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in 'block in RuboCop::AST::Traversal#on_dstr'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in 'Array#each'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in 'RuboCop::AST::Traversal#on_dstr'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:71:in 'RuboCop::Cop::Commissioner#on_begin'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:163:in 'RuboCop::AST::Traversal#on_def'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:71:in 'RuboCop::Cop::Commissioner#on_def'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in 'block in RuboCop::AST::Traversal#on_dstr'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in 'Array#each'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in 'RuboCop::AST::Traversal#on_dstr'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:71:in 'RuboCop::Cop::Commissioner#on_begin'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:163:in 'RuboCop::AST::Traversal#on_class'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:71:in 'RuboCop::Cop::Commissioner#on_class'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in 'block in RuboCop::AST::Traversal#on_dstr'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in 'Array#each'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in 'RuboCop::AST::Traversal#on_dstr'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:71:in 'RuboCop::Cop::Commissioner#on_begin'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:20:in 'RuboCop::AST::Traversal#walk'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:87:in 'RuboCop::Cop::Commissioner#investigate'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/team.rb:174:in 'RuboCop::Cop::Team#investigate_partial'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/team.rb:101:in 'RuboCop::Cop::Team#investigate'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:348:in 'block in RuboCop::Runner#inspect_file'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:347:in 'Array#each'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:347:in 'Enumerable#flat_map'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:347:in 'RuboCop::Runner#inspect_file'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:290:in 'block in RuboCop::Runner#do_inspection_loop'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:324:in 'block in RuboCop::Runner#iterate_until_no_changes'
	from <internal:kernel>:168:in 'Kernel#loop'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:317:in 'RuboCop::Runner#iterate_until_no_changes'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:286:in 'RuboCop::Runner#do_inspection_loop'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:167:in 'block in RuboCop::Runner#file_offenses'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:192:in 'RuboCop::Runner#file_offense_cache'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-md-2.0.2/lib/rubocop/markdown/rubocop_ext.rb:47:in 'file_offense_cache'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:166:in 'RuboCop::Runner#file_offenses'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:154:in 'RuboCop::Runner#process_file'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:135:in 'block in RuboCop::Runner#each_inspected_file'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:134:in 'Array#each'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:134:in 'Enumerable#reduce'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:134:in 'RuboCop::Runner#each_inspected_file'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:120:in 'RuboCop::Runner#inspect_files'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:73:in 'RuboCop::Runner#run'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/lsp/stdin_runner.rb:54:in 'RuboCop::Lsp::StdinRunner#run'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/lsp/runtime.rb:43:in 'RuboCop::LSP::Runtime#format'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/ruby_lsp/rubocop/runtime_adapter.rb:28:in 'RubyLsp::RuboCop::RuntimeAdapter#run_formatting'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/ruby-lsp-0.26.1/lib/ruby_lsp/requests/formatting.rb:35:in 'RubyLsp::Requests::Formatting#perform'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/ruby-lsp-0.26.1/lib/ruby_lsp/server.rb:648:in 'RubyLsp::Server#text_document_formatting'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/ruby-lsp-0.26.1/lib/ruby_lsp/server.rb:46:in 'RubyLsp::Server#process_message'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/ruby-lsp-0.26.1/lib/ruby_lsp/base_server.rb:168:in 'block in RubyLsp::BaseServer#new_worker'
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/layout/indentation_width.rb:266:in 'RuboCop::Cop::Layout::IndentationWidth#check_if': undefined method 'else' for an instance of Parser::Source::Map::Keyword (NoMethodError)

          check_indentation(node.loc.else, else_clause)
                                    ^^^^^
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/layout/indentation_width.rb:161:in 'RuboCop::Cop::Layout::IndentationWidth#on_if'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:107:in 'Kernel#public_send'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:107:in 'block (2 levels) in RuboCop::Cop::Commissioner#trigger_responding_cops'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:171:in 'RuboCop::Cop::Commissioner#with_cop_error_handling'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:106:in 'block in RuboCop::Cop::Commissioner#trigger_responding_cops'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:105:in 'Array#each'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:105:in 'RuboCop::Cop::Commissioner#trigger_responding_cops'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:69:in 'RuboCop::Cop::Commissioner#on_if'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in 'block in RuboCop::AST::Traversal#on_dstr'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in 'Array#each'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in 'RuboCop::AST::Traversal#on_dstr'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:71:in 'RuboCop::Cop::Commissioner#on_begin'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:163:in 'RuboCop::AST::Traversal#on_def'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:71:in 'RuboCop::Cop::Commissioner#on_def'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in 'block in RuboCop::AST::Traversal#on_dstr'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in 'Array#each'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in 'RuboCop::AST::Traversal#on_dstr'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:71:in 'RuboCop::Cop::Commissioner#on_begin'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:163:in 'RuboCop::AST::Traversal#on_class'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:71:in 'RuboCop::Cop::Commissioner#on_class'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in 'block in RuboCop::AST::Traversal#on_dstr'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in 'Array#each'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in 'RuboCop::AST::Traversal#on_dstr'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:71:in 'RuboCop::Cop::Commissioner#on_begin'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:20:in 'RuboCop::AST::Traversal#walk'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/commissioner.rb:87:in 'RuboCop::Cop::Commissioner#investigate'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/team.rb:174:in 'RuboCop::Cop::Team#investigate_partial'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/cop/team.rb:101:in 'RuboCop::Cop::Team#investigate'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:348:in 'block in RuboCop::Runner#inspect_file'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:347:in 'Array#each'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:347:in 'Enumerable#flat_map'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:347:in 'RuboCop::Runner#inspect_file'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:290:in 'block in RuboCop::Runner#do_inspection_loop'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:324:in 'block in RuboCop::Runner#iterate_until_no_changes'
	from <internal:kernel>:168:in 'Kernel#loop'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:317:in 'RuboCop::Runner#iterate_until_no_changes'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:286:in 'RuboCop::Runner#do_inspection_loop'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:167:in 'block in RuboCop::Runner#file_offenses'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:192:in 'RuboCop::Runner#file_offense_cache'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-md-2.0.2/lib/rubocop/markdown/rubocop_ext.rb:47:in 'file_offense_cache'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:166:in 'RuboCop::Runner#file_offenses'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:154:in 'RuboCop::Runner#process_file'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:135:in 'block in RuboCop::Runner#each_inspected_file'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:134:in 'Array#each'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:134:in 'Enumerable#reduce'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:134:in 'RuboCop::Runner#each_inspected_file'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:120:in 'RuboCop::Runner#inspect_files'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/runner.rb:73:in 'RuboCop::Runner#run'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/lsp/stdin_runner.rb:54:in 'RuboCop::Lsp::StdinRunner#run'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/rubocop/lsp/runtime.rb:43:in 'RuboCop::LSP::Runtime#format'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/rubocop-1.80.0/lib/ruby_lsp/rubocop/runtime_adapter.rb:28:in 'RubyLsp::RuboCop::RuntimeAdapter#run_formatting'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/ruby-lsp-0.26.1/lib/ruby_lsp/requests/formatting.rb:35:in 'RubyLsp::Requests::Formatting#perform'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/ruby-lsp-0.26.1/lib/ruby_lsp/server.rb:648:in 'RubyLsp::Server#text_document_formatting'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/ruby-lsp-0.26.1/lib/ruby_lsp/server.rb:46:in 'RubyLsp::Server#process_message'
	from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.4.0/gems/ruby-lsp-0.26.1/lib/ruby_lsp/base_server.rb:168:in 'block in RubyLsp::BaseServer#new_worker'

Steps to reproduce the problem

I have not yet found a simple reproduction for this. If you happen to have Homebrew installed, you can take the following steps:

  1. Open the Homebrew codebase in VSCode with code $(brew --repository)
  2. Change the workspace settings to use the rubocop formatter (it was changed to work around this bug)
  3. Restart the Ruby LSP
  4. Open a Ruby file
  5. Create a RuboCop violation that is auto-correctable (e.g. indent a line of code too much)
  6. Attempt to format the file by saving or manually formatting, and observe the error shown above

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler.
If you see extension cop versions (e.g. rubocop-performance, rubocop-rspec, and others)
output by rubocop -V, include them as well. Here's an example:

$ brew rubocop -V
1.80.0 (using Parser 3.3.9.0, rubocop-ast 1.46.0, analyzing as Ruby 2.7, running on ruby 3.4.5) [arm64-darwin20]
  - rubocop-md 2.0.2
  - rubocop-performance 1.25.0
  - rubocop-rspec 3.6.0
  - rubocop-sorbet 0.10.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions