簡體   English   中英

rubocop 無法加載此類文件 -- rubocop-rails

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

我安裝了 gem 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>'

請幫幫我 !!!

好像你有這樣的東西: require: rubocop-rails在你的 rubocop 配置文件鏈中的某個地方。 但是您還沒有在您的 gemfile 中包含gem 'rubocop-rails'

請在您的 gemfile 中包含 gem 'rubocop-rails',這應該得到解決。

您使用哪個版本的 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM