2

When opening a ruby file in VSCode I get the error:

.rubocop.yml: Metrics/LineLength has the wrong namespace - should be Layout Error: The `Style/BracesAroundHashParameters` cop has been removed. (obsolete configuration found in .rubocop.yml, please update it)

So linting in VSCode doesn't work. The reason is obvious: The LineLength cop is under the Metrics namespace, since the project uses rubocop 0.77.0 and moving it to Layout was introduced in 0.78.0. So changing the namespace would mean that running bundle exec rubocop would fail. As would the Travis build.

I'm unclear how I can specify the version that vscode itself is using, if it is a globally installed gem and how I can set the rubocop version for vscode specifically for each project - since I have different projects with different versions of Ruby and rubocop.

Thanks!

Ole Spaarmann
  • 15,845
  • 27
  • 98
  • 160
  • 1
    Do you have `rubocop` in your project's Gemfile? If so, do `bundle install` and it should work. If not, try looking at the *Execute path* setting of Rubocop in VS Code settings. – gd_silva May 14 '20 at 15:49
  • @gd.silva yes I have but it doesn't change anything... – Ole Spaarmann Jun 25 '20 at 08:04

1 Answers1

2

I had this same issue just happen to me. At some point i must have installed the rubocop gem globally on my system rather than just within the project. The fix for me was influenced by this answer. Essentially

bundle exec rubocop -v
rubocop -v

If these two values are different continue:

gem uninstall rubocop

You will then be presented with a list of the installed versions. Select the one that doesnt match up with your bundle installed version, and confirm. At this point you can confirm that the uninstall was successful by running

rubocop -v

And you should see the version that was listed as part of your bundle.

haxxxton
  • 6,422
  • 3
  • 27
  • 57