首先,我检查了是否实际安装了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中,我创建了一个具有:
@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
。
我不知道我还能做什么。
发布于 2020-09-25 22:44:48
我刚刚放弃了ruby-rubocop
扩展并安装了Ruby Solargraph
。就像一种魅力。
发布于 2021-02-03 15:53:55
尝试将rubocop版本更新为1.9.1 (运行此操作应该有效)
gem install rubocop
发布于 2022-08-06 11:31:38
对于ruby.rubocop.executePath
使用UNC路径,以及创建一个rubocop.bat
,我的运气稍微好一些。所以,我在我的设定中:
"ruby.rubocop.executePath": "\\\\wsl.localhost\\Ubuntu\\home\\charles\\.rbenv\\shims\\",
我使用了你的rubocop.bat
文件,这似乎是Windows上的代码想要的。虽然这看起来确实奏效了,但(令人不快地)缓慢。我正在使用WSL2。
https://stackoverflow.com/questions/64071957
复制相似问题