LoginSignup
4
7

More than 5 years have passed since last update.

rubocopがエラーになる(`require': cannot load such file -- rubocop-rspec)

Last updated at Posted at 2016-12-14
エラー内容
$ rubocop

/Users/user_name/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- rubocop-rspec (LoadError)
  from /Users/user_name/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /Users/user_name/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rubocop-0.46.0/lib/rubocop/config_loader_resolver.rb:15:in `block in resolve_requires'
  from /Users/user_name/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rubocop-0.46.0/lib/rubocop/config_loader_resolver.rb:11:in `each'
  from /Users/user_name/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rubocop-0.46.0/lib/rubocop/config_loader_resolver.rb:11:in `resolve_requires'
  from /Users/user_name/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rubocop-0.46.0/lib/rubocop/config_loader.rb:40:in `load_file'
  from /Users/user_name/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rubocop-0.46.0/lib/rubocop/config_loader.rb:105:in `configuration_from_file'
  from /Users/user_name/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rubocop-0.46.0/lib/rubocop/config_store.rb:44:in `for'
  from /Users/user_name/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cli.rb:93:in `apply_default_formatter'
  from /Users/user_name/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cli.rb:25:in `run'
  from /Users/user_name/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rubocop-0.46.0/bin/rubocop:13:in `block in <top (required)>'
  from /Users/user_name/.rbenv/versions/2.3.1/lib/ruby/2.3.0/benchmark.rb:308:in `realtime'
  from /Users/user_name/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rubocop-0.46.0/bin/rubocop:12:in `<top (required)>'
  from /Users/user_name/.rbenv/versions/2.3.1/bin/rubocop:23:in `load'
  from /Users/user_name/.rbenv/versions/2.3.1/bin/rubocop:23:in `<main>'
解決策

.rubocop.yml

require: rubocop-rspec

という記述を以下に変更する

AllCops:
  Include:
    - rubocop-rspec
Thanks

version
$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]

$ rubocop -v
0.46.0
4
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
7