"rubocop failed with code=2" error when saving a file in VSCode
See original GitHub issueYour environment
vscode-ruby
version: 0.22.3- Ruby version: tried with 2.6.2 and 2.5.1
- Ruby version manager (if any): rvm 1.29.7 (latest)
- VS Code version: 1.33.1
- Operating System: MacOS Mojave 10.14.4
- Using language server? I believe I am. 😃
Expected behavior
Rubocop lints the file and autofixes
Actual behavior

No linting/autofixing when running on 2.5.1 or 2.6.2
Here is my settings.json
:
{
"editor.wordWrap": "on",
"editor.tabSize": 2,
"git.confirmSync": false,
"editor.detectIndentation": false,
"editor.formatOnSave": true,
"workbench.startupEditor": "newUntitledFile",
// "editor.parameterHints": false,
"git.autofetch": true,
"window.zoomLevel": 0,
"ruby.intellisense": "rubyLocate",
"ruby.lint": {
"rubocop": {
"lint": true,
"rails": true
}
},
"ruby.useLanguageServer": true,
"[ruby]": {
"editor.formatOnSave": true
},
"ruby.format": "rubocop",
"editor.formatOnSaveTimeout": 1500
}
When I’m in a workspace for a ruby 2.6.2 project, I get the error popup and it doesn’t lint. When I’m in a workspace for a ruby 2.5.1 project, I don’t get the error popup, but it still doesn’t lint.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:17
Top Results From Across the Web
Rubocop: Error - rubocop returned exit code 2 - Stack Overflow
According to RuboCop HQ commit message in relation to this issue (Return exit code 2 if RuboCop fails due to internal error), it...
Read more >Error Rubocop Returned Exit Code 2 - ADocLib
Error :Rubocop returned exit code: 2 Invocation from the command line on the root of the project works. For one file or the...
Read more >Remote Development Tips and Tricks - Visual Studio Code
In VS Code, run Remote-SSH: Open Configuration File... in the Command ... Save the converted key to a local location under the .ssh...
Read more >Basic Usage :: RuboCop Docs
Running rubocop with no arguments will check all Ruby source files in the current directory: ... Use A or autocorrect if you'd like...
Read more >RuboCop | RubyMine Documentation - JetBrains
Run RuboCop on save · In the Settings/Preferences dialog ( Ctrl+Alt+S ), select Editor | Inspections. · Select the RuboCop inspection under Ruby ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@wingrunr21 Ah, didn’t know about that page. Still, on a failing rubocop format:
…
Ruby: Show Language Server Output Channel
doesn’t seem to be defined:…and
Ruby: Show Output Channel
show an empty page:If you want I can try and make a reproduction. Specifically this repo requires bundler, so I set
"ruby.useBundler": false,
to get this error.Was there a resolution to this? I’m seeing the same behaviour. When I run in the terminal, it corrects the problem and exits with a code of
0
. I haven’t figured out how to turn on the verbose logging (fairly new to vscode) so I don’t see anything in the output tab.