Ruby on rails ruby Rubocp无法加载这样的文件——rubocp/rspec/focused

Ruby on rails ruby Rubocp无法加载这样的文件——rubocp/rspec/focused,ruby-on-rails,ruby,rubygems,rubocop,rubocop-rspec,Ruby On Rails,Ruby,Rubygems,Rubocop,Rubocop Rspec,我安装了ruby Rubocp for VSCode,gem安装了Rubocp,但每次保存文件时,都会抛出以下错误: 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' /Syste

我安装了ruby Rubocp for VSCode,gem安装了Rubocp,但每次保存文件时,都会抛出以下错误:

    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)>'
无法加载这样的文件——rubocp/rspec/focused
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/Ruby/2.6.0/rubygems/core\u ext/kernel\u require.rb:54:in'require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/Ruby/2.6.0/rubygems/core\u ext/kernel\u require.rb:54:in'require'
/Library/Ruby/Gems/2.6.0/Gems/rubocop-0.85.0/lib/rubocop/config\u loader\u resolver.rb:15:in“block in resolve\u requires”
/Library/Ruby/Gems/2.6.0/Gems/rubocop-0.85.0/lib/rubocop/config\u loader\u resolver.rb:11:in'each'
/Library/Ruby/Gems/2.6.0/Gems/rubocop-0.85.0/lib/rubocop/config\u loader\u resolver.rb:11:in'resolve\u 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\u finder.rb:180:在“进程中的块显式路径”中
/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\u finder.rb:179:in'process\u explicit\u 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:在“查找目标文件”中
/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\u runner.rb:21:in'execute\u 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_命令'
/Library/Ruby/Gems/2.6.0/Gems/rubocop-0.85.0/lib/rubocop/cli.rb:72:in'execute_runner'
/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'

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

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

找到并修复了该问题

事实证明,罪魁祸首是:

  • rubocop-v0.85.0
  • rubocop公司
  • 由于我们的组织使用的是较旧的版本,所以修复程序只是将两者降级。所以现在我安装了:

  • rubocop-v0.75.1
  • Rubocp rspec聚焦

  • 我已经安装了rubocop rspe,重新启动了,但仍然出现了相同的错误。任何插件都应该在.rubocop.yml文件中显式启用。以Rubocp rspec为重点的gem不再维护,因此切换到已存档且不再维护的官方Rubocp rspec是有意义的。