简体   繁体   English

ruby-rubocop 无法加载此类文件 — rubocop/rspec/focused

[英]ruby-rubocop cannot load such file — rubocop/rspec/focused

I've installed ruby-rubocop for VSCode, and gem installed rubocop, but every time I save a file, this error is thrown:我已经为 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)>'

Please help, I've been trying to make this work, and scouring the internet for solutions.请帮忙,我一直在努力完成这项工作,并在互联网上寻找解决方案。 but haven't had any luck yet.但还没有运气。

That cop is part of the rubocop-rspec plug-in, so you may also have to run gem install rubocop-rspec .该 cop 是rubocop-rspec插件的一部分,因此您可能还必须运行gem install rubocop-rspec

Found and fixed the issue.发现并解决了问题。

As it turns out, the culprits are:事实证明,罪魁祸首是:

  1. rubocop -v 0.85.0 rubocop -v 0.85.0
  2. rubocop-rspec rubocop-rspec

The fix was just to downgrade both since our organization is using the older versions.由于我们的组织使用的是旧版本,因此修复只是降级。 So now I installed:所以现在我安装了:

  1. rubocop -v 0.75.1 rubocop -v 0.75.1
  2. rubocop-rspec-focused rubocop-rspec-focused

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM