WSL2 中 VSCODE 的配置 Rubocop 错误

Error on config Rubocop for VSCODE in WSL2

首先我检查了 gem 是否真的安装了:

rubocop -v => 0.92.0

然后,检查 rubocop 可执行文件的安装位置:

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

VSCODE > Settings.json 中:"ruby.rubocop.executePath": "" 推荐 https://github.com/misogi/vscode-ruby-rubocop#configuration

当我尝试执行时:command /home/joao/.rbenv/shims/rubocop returns empty output! please check configuration./home/joao/.rbenv/shims/rubocop is not executable

所以我尝试手动添加路径:"ruby.rubocop.executePath": "/home/joao/.rbenv/shims/" 同样的错误仍然存​​在:command /home/joao/.rbenv/shims/rubocop returns empty output! please check configuration./home/joao/.rbenv/shims/rubocop is not executable

然后我尝试了 rbenv which rubocop => "ruby.rubocop.executePath": "/home/joao/.rbenv/versions/2.6.6/bin/" 的路径 同样的错误仍然存​​在:command /home/joao/.rbenv/versions/2.6.6/bin/rubocop returns empty output! please check configuration./home/joao/.rbenv/versions/2.6.6/bin/rubocop is not executable

最后一次尝试:在 windows 中创建一个 bash 脚本以指向 rubocop。

在:c:\my_scripts 我创建了一个 rubocop.bat 具有:

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

然后在 VSCODE 中:"ruby.rubocop.executePath": "c:/my_scripts/", 仍然是同样的错误:command c:/my_scripts/rubocop returns empty output! please check configuration.c:/my_scripts/rubocop is not executable.

我不知道我还能做什么。

我刚刚放弃了 ruby-rubocop 扩展并安装了 Ruby Solargraph。 就像一个魅力。

尝试将 rubocop 版本更新到 1.9.1 (运行 这应该有效)

gem install rubocop