简体   繁体   English

rubocop 无法加载此类文件 -- rubocop-rails

[英]rubocop cannot load such file -- rubocop-rails

I installed gem rubocop .我安装了 gem rubocop When I run: command rubocop terminal respond:当我运行时:命令rubocop终端响应:

longnguyen:~/RubyOnRails/project$ rubocop
cannot load such file -- rubocop-rails
/home/sun/.rvm/gems/ruby-2.5.3/gems/rubocop-0.72.0/lib/rubocop/config_loader_resolver.rb:15:in `require'
/home/sun/.rvm/gems/ruby-2.5.3/gems/rubocop-0.72.0/lib/rubocop/config_loader_resolver.rb:15:in `block in resolve_requires'
/home/sun/.rvm/gems/ruby-2.5.3/gems/rubocop-0.72.0/lib/rubocop/config_loader_resolver.rb:11:in `each'
/home/sun/.rvm/gems/ruby-2.5.3/gems/rubocop-0.72.0/lib/rubocop/config_loader_resolver.rb:11:in `resolve_requires'
/home/sun/.rvm/gems/ruby-2.5.3/gems/rubocop-0.72.0/lib/rubocop/config_loader.rb:45:in `load_file'
/home/sun/.rvm/gems/ruby-2.5.3/gems/rubocop-0.72.0/lib/rubocop/config_loader.rb:86:in `configuration_from_file'
/home/sun/.rvm/gems/ruby-2.5.3/gems/rubocop-0.72.0/lib/rubocop/config_store.rb:44:in `for'
/home/sun/.rvm/gems/ruby-2.5.3/gems/rubocop-0.72.0/lib/rubocop/cli.rb:242:in `apply_default_formatter'
/home/sun/.rvm/gems/ruby-2.5.3/gems/rubocop-0.72.0/lib/rubocop/cli.rb:50:in `run'
/home/sun/.rvm/gems/ruby-2.5.3/gems/rubocop-0.72.0/exe/rubocop:13:in `block in <top (required)>'
/home/sun/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
/home/sun/.rvm/gems/ruby-2.5.3/gems/rubocop-0.72.0/exe/rubocop:12:in `<top (required)>'
/home/sun/.rvm/gems/ruby-2.5.3/bin/rubocop:23:in `load'
/home/sun/.rvm/gems/ruby-2.5.3/bin/rubocop:23:in `<main>'
/home/sun/.rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `eval'
/home/sun/.rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `<main>'

Help me please !!!请帮帮我 !!!

Seems like you have something like: require: rubocop-rails somewhere in your rubocop configuration files chain.好像你有这样的东西: require: rubocop-rails在你的 rubocop 配置文件链中的某个地方。 But you have not included gem 'rubocop-rails' in your gemfile.但是您还没有在您的 gemfile 中包含gem 'rubocop-rails'

Please include gem 'rubocop-rails' in your gemfile and this should be resolved.请在您的 gemfile 中包含 gem 'rubocop-rails',这应该得到解决。

Which version of rubocop-rails do you use?您使用哪个版本的 rubocop-rails?

In my case with 2.1.0 version was fine.就我而言,2.1.0 版本很好。

$ bundle update rubocop-rails
...
Installing rubocop-rails 2.1.0 (was 1.5.0)
Bundle updated!

$ bundle console
Frame number: 0/18
[1] pry(main)> require 'rubocop-rails'
=> true

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

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