Search code examples
rubyvisual-studio-coderbenvrubocop

Error on config Rubocop for VSCODE in WSL2


First I've checked if the gem is actually installed:

rubocop -v => 0.92.0

Then, checking where's rubocop executable is installed:

which rubocop => /home/joao/.rbenv/shims/rubocop
in rbenv:
rbenv which rubocop => /home/joao/.rbenv/versions/2.6.6/bin/rubocop

In VSCODE > Settings.json: "ruby.rubocop.executePath": "" as recomended https://github.com/misogi/vscode-ruby-rubocop#configuration

When I try to execute: command /home/joao/.rbenv/shims/rubocop returns empty output! please check configuration. and /home/joao/.rbenv/shims/rubocop is not executable

So I tried to manually add the path: "ruby.rubocop.executePath": "/home/joao/.rbenv/shims/" The same error persists: command /home/joao/.rbenv/shims/rubocop returns empty output! please check configuration. and /home/joao/.rbenv/shims/rubocop is not executable

Then I tried the path of rbenv which rubocop => "ruby.rubocop.executePath": "/home/joao/.rbenv/versions/2.6.6/bin/" The same error persists: command /home/joao/.rbenv/versions/2.6.6/bin/rubocop returns empty output! please check configuration. and /home/joao/.rbenv/versions/2.6.6/bin/rubocop is not executable

A last try: create a bash script in windows to point to rubocop.

In: c:\my_scripts I created a rubocop.bat having:

@echo off
bash.exe -c "~/.rbenv/shims/rubocop %*"

Then in VSCODE: "ruby.rubocop.executePath": "c:/my_scripts/", still the same erros: command c:/my_scripts/rubocop returns empty output! please check configuration. and c:/my_scripts/rubocop is not executable.

I have no idea whatelse I can do.


Solution

  • I just gave up from ruby-rubocop extension and installed Ruby Solargraph. Works like a charm.