简体   繁体   中英

rubocop cannot load such file -- rubocop-rails

I installed gem rubocop . When I run: command rubocop terminal respond:

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. But you have not included gem 'rubocop-rails' in your gemfile.

Please include gem 'rubocop-rails' in your gemfile and this should be resolved.

Which version of rubocop-rails do you use?

In my case with 2.1.0 version was fine.

$ 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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