Rubocop: Rubocop 0.64.0 failing without rubocop-rspec installed

Created on 10 Feb 2019  路  4Comments  路  Source: rubocop-hq/rubocop

After upgrade to Rubocop 0.64.0, it fails on not being able to find rubocop-rspec, which the project I'm working on doesn't require (and we have had no configuration changes since the recent successful run with 0.63.1).

Note that this did happen in gitlab CI. I don't see how it possibly could be causing rubocop to demand rspec, but I will be doing testing to ensure this is actually rubocop's fault.


Expected behavior

Successful running after installing the gem, as here with 0.63.1:

$ gem install rubocop
Building native extensions. This could take a while...
Successfully installed jaro_winkler-1.5.2
Successfully installed parallel-1.13.0
Successfully installed ast-2.4.0
Successfully installed parser-2.6.0.0
Successfully installed powerpack-0.1.2
Successfully installed rainbow-3.0.0
Successfully installed ruby-progressbar-1.10.0
Successfully installed unicode-display_width-1.4.1
Successfully installed rubocop-0.63.1
9 gems installed
$ rubocop
Inspecting 404 files
....................................................................................................................................................................................................................................................................................................................................................................................................................

404 files inspected, no offenses detected

Actual behavior

Failure:

$ gem install rubocop
Building native extensions. This could take a while...
Successfully installed jaro_winkler-1.5.2
Successfully installed parallel-1.13.0
Successfully installed ast-2.4.0
Successfully installed parser-2.6.0.0
Successfully installed powerpack-0.1.2
Successfully installed rainbow-3.0.0
Successfully installed ruby-progressbar-1.10.0
Successfully installed unicode-display_width-1.4.1
Successfully installed rubocop-0.64.0
9 gems installed
$ rubocop
cannot load such file -- rubocop-rspec
/usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/config_loader_resolver.rb:15:in `block in resolve_requires'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/config_loader_resolver.rb:11:in `each'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/config_loader_resolver.rb:11:in `resolve_requires'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/config_loader.rb:44:in `load_file'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/config_loader.rb:82:in `configuration_from_file'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/config_store.rb:44:in `for'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/target_finder.rb:154:in `ruby_interpreters'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/target_finder.rb:147:in `ruby_executable?'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/target_finder.rb:163:in `ruby_file?'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/target_finder.rb:76:in `to_inspect?'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/target_finder.rb:65:in `block in target_files_in_dir'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/target_finder.rb:64:in `select'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/target_finder.rb:64:in `target_files_in_dir'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/target_finder.rb:31:in `find'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/runner.rb:67:in `find_target_files'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/runner.rb:43:in `run'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/cli.rb:174:in `execute_runner'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/cli.rb:75:in `execute_runners'
/usr/local/bundle/gems/rubocop-0.64.0/lib/rubocop/cli.rb:47:in `run'
/usr/local/bundle/gems/rubocop-0.64.0/exe/rubocop:13:in `block in <top (required)>'
/usr/local/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
/usr/local/bundle/gems/rubocop-0.64.0/exe/rubocop:12:in `<top (required)>'
/usr/local/bundle/bin/rubocop:23:in `load'
/usr/local/bundle/bin/rubocop:23:in `<main>'

Steps to reproduce the problem

Don't install rubocop-rspec, don't require it in .rubocop.yml, then run rubocop.

RuboCop version

0.64.0

Most helpful comment

So I was having the same problem, also with GitLab CI. Turns out it was because I put my gems in ./vendor/ directory, which contains another rubocop config file with the offending require statement inside. So I just had to exclude the vendor directory in my project's .rubocop.yml file.

Just in case anyone ever need it, because I spent to much time on this than I'd like to admit 馃檲

All 4 comments

Further testing showed this to be some kind of very, very bizarre issue with gitlab CI caching and almost certainly not actually Rubocop's fault.

Did you manage to fix that or find a more consistent way to reproduce it? I'm faced with the exact same issue with one of my projects on gitlab. I never required rubocop-rspec anywhere, but I'm still getting this error. Clearing runners' cache doesn't help. And I can't reproduce it on a fresh project. It's bizarre for sure.

The problem has disappeared as soon as I completely removed cache directive from .gitlab-ci.yml. I couldn't determine what exactly led to the error in the first place, but I've already spent too much time on this. Maybe later I will be able trace it down and report a bug to gitlab.
Sorry for polluting rubocop tracker.

So I was having the same problem, also with GitLab CI. Turns out it was because I put my gems in ./vendor/ directory, which contains another rubocop config file with the offending require statement inside. So I just had to exclude the vendor directory in my project's .rubocop.yml file.

Just in case anyone ever need it, because I spent to much time on this than I'd like to admit 馃檲

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benoittgt picture benoittgt  路  3Comments

AndreiMotinga picture AndreiMotinga  路  3Comments

Aqualon picture Aqualon  路  3Comments

tedPen picture tedPen  路  3Comments

bbugh picture bbugh  路  3Comments