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
RuboCop is a Ruby code style checking and code formatting tool. It aims to enforce the community-driven Ruby Style Guide.
The accepted answer didn't work for me. However, I did find a comment by jdarnok
on this GitHub issue that worked for me.
First, to get the user's path of the program file, I ran:
rbenv which rubocop
which gave me this result:
/Users/<your username>/.rbenv/versions/2.6.2/gemsets/Rails4.2_EnergyLink/bin/rubocop
Then I ran:
which rubocop
which gave me this result:
/Users/<your username>/.rbenv/shims/rubocop
SOLUTION
In the settings of VS Code under Ruby > Rubocop: Execute Path
I pasted:
/Users/<your username>/.rbenv/shims/
Other potential solutions
This Stackoverflow post refers to a few other potential solutions, such as:
bin
in the PATH with wrappers
executable hooks
Make sure you installed Rubocop in the first place.
gem install rubocop
You can check that it works properly like this:
rubocop -v
Search for ruby-rubocop
in the marketplace and install it.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With