我安装了宝石rubocop。当我跑步时:
命令
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>'
请帮帮我!
答案 0 :(得分:1)
好像您有以下内容:
require: rubocop-rails
在rubocop配置文件链中的某个位置。但是您没有在自己的gemfile中包含gem 'rubocop-rails'
。
请在您的gemfile中包含gem'rubocop-rails',这应该可以解决。
答案 1 :(得分:0)
您使用哪个版本的rubocop-rails?
以我的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