问题描述
首先,我检查了是否已实际安装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
。
我不知道还能做什么。
解决方法
尝试将 rubocop 版本更新到 1.9.1 (运行这个应该可以)
<?php
class testClass
{
public function GetData()
{
return "Hello World";
}
}
?>