Ruby-Rubocop 无法加载这样的文件 - RuboCop/Rspec/Focused



我已经为 VSCode 安装了 ruby-rubocop,并且 gem 安装了 rubocop,但是每次保存文件时,都会抛出此错误:

cannot load such file -- rubocop/rspec/focused
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/config_loader_resolver.rb:15:in `block in resolve_requires'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/config_loader_resolver.rb:11:in `each'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/config_loader_resolver.rb:11:in `resolve_requires'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/config_loader.rb:45:in `load_file'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/config_loader.rb:90:in `configuration_from_file'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/config_store.rb:54:in `for_dir'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/config_store.rb:44:in `for'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/target_finder.rb:180:in `block in process_explicit_path'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/target_finder.rb:179:in `reject'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/target_finder.rb:179:in `process_explicit_path'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/target_finder.rb:39:in `block in find'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/target_finder.rb:35:in `each'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/target_finder.rb:35:in `find'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/runner.rb:69:in `find_target_files'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/runner.rb:34:in `run'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cli/command/execute_runner.rb:21:in `execute_runner'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cli/command/execute_runner.rb:13:in `run'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cli/command.rb:10:in `run'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cli/environment.rb:17:in `run'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cli.rb:65:in `run_command'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cli.rb:72:in `execute_runners'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cli.rb:41:in `run'
/Library/Ruby/Gems/2.6.0/gems/rubocop-0.85.0/exe/rubocop:13:in `block in <top (required)>'

请帮忙!我一直在努力做到这一点,并在互联网上搜索解决方案,但还没有运气。

该 cop 是 rubocop-rspec 插件的一部分,因此您可能还必须运行gem install rubocop-rspec

找到并修复了问题。

事实证明,罪魁祸首是:

  1. 红波猫 -v 0.85.0
  2. 鲁波科普-RSPEC

修复只是降级两者,因为我们的组织正在使用旧版本。所以现在我安装了:

  1. 红波猫 -V 0.75.1
  2. 以红波豹-RSPEC为重点

最新更新