question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"rubocop failed with code=2" error when saving a file in VSCode

See original GitHub issue

Your 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

Screen Shot 2019-04-12 at 10 06 03 AM error popup when running on 2.6.2

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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:17

github_iconTop GitHub Comments

5reactions
bmalehorncommented, Sep 30, 2019

@wingrunr21 Ah, didn’t know about that page. Still, on a failing rubocop format:

image

Ruby: Show Language Server Output Channel doesn’t seem to be defined:

image

…and Ruby: Show Output Channel show an empty page:

image

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.

5reactions
retnuhcommented, Jul 18, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found