Ruby-Rubocop无法在vscode上运行

smm*_*r14 5 debugging rubocop visual-studio-code

/Users/me/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb:289:in ``find_spec_for_exe': can't find gem rubocop (>= 0.a) with executable rubocop (Gem::GemNotFoundException) from /Users/me/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb:308:in ``activate_bin_path' from /Users/me/.rbenv/versions/2.5.1/bin/rubocop:23:in'

这是我每次输入内容时都会遇到的错误。有谁知道如何解决这个问题?

小智 8

经过许多痛苦的时间并阅读其他解决方案后,我终于推断答案是从根安装 Rubocop。当我尝试时,以下步骤有效。您首先需要进入终端中的根目录。安装Rubocop然后找到路径并将其添加到Rubocop设置中的执行路径

$ cd ~
$ gem install rubocop
$ which rubocop
Paste location given in Ruby-Rubocop configuration settings > Execute Path
/Users/username/.rvm/gems/ruby-2.6.1/bin/
Run Code Online (Sandbox Code Playgroud)


rad*_*lov 2

我可以向您推荐两个解决方案,因为我也遇到过同样的问题:

  • bundler对我来说,安装sudo->sudo gem install bundler解决问题。

  • 也可能是您的RubyGems版本出现错误。好像ruby -v2.5有兼容问题RubyGems -v2.7.3。因此,请尝试将其升级RubyGems-v2.7.4使用该gem update --system命令。