Search code examples
rubyvisual-studio-coderubocop

rubocop on VScode not working.Error "rubocop is not executable"


Recently I installed rubocop on vscode. However, it doesn't work.Error message is below.

rubocop is not excutable 
execute path is empty! please check ruby.rubocop.executePath

How should I fix it? I searched some articles, never solved...

cf. vscode-ruby-rubocop https://github.com/misogi/vscode-ruby-rubocop


Solution

  • tl;dr

    Make sure you installed Rubocop in the first place.

    VS Code Rubocop Tutorial

    Install Rubocop

    gem install rubocop
    

    You can check that it works properly like this:

    rubocop -v
    

    Install VS Code extension

    Search for ruby-rubocop in the marketplace and install it.

    Install Rubocop VS Code marketplace

    Configure Rubocop for your project

    Add a .rubocop.yml file to your project's root. You can see all the configuration options and how such a file should look like in the default config file. Be aware that if there are outdated or wrong rules in the file, you will get an error and Rubocop won't work. VS Code will alert you about this:

    Rubocop config errors