rubocop: Can't execute v1.34.0 with error "cannot load such file -- rubocop-rails"
I can’t run rubocop v1.34.0. Downgrading to v1.33.0, I could run it correctly.
Expected behavior
In the rails project,
- execute
% rubocop - then execute correctly
Actual behavior
% rubocop --debug
For /path-to/ruby-project: configuration from /path-to/ruby-project/.rubocop.yml
cannot load such file -- rubocop-rails
/path-to/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubocop-1.34.0/lib/rubocop/feature_loader.rb:33:in `require'
/path-to/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubocop-1.34.0/lib/rubocop/feature_loader.rb:33:in `load'
/path-to/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubocop-1.34.0/lib/rubocop/feature_loader.rb:21:in `load'
/path-to/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubocop-1.34.0/lib/rubocop/config_loader_resolver.rb:14:in `block (2 levels) in resolve_requires'
/path-to/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubocop-1.34.0/lib/rubocop/config_loader_resolver.rb:13:in `each'
/path-to/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubocop-1.34.0/lib/rubocop/config_loader_resolver.rb:13:in `block in resolve_requires'
<internal:kernel>:90:in `tap'
/path-to/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubocop-1.34.0/lib/rubocop/config_loader_resolver.rb:12:in `resolve_requires'
/path-to/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubocop-1.34.0/lib/rubocop/config_loader.rb:46:in `load_file'
/path-to/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubocop-1.34.0/lib/rubocop/config_loader.rb:104:in `configuration_from_file'
/path-to/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubocop-1.34.0/lib/rubocop/config_store.rb:68:in `for_dir'
/path-to/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubocop-1.34.0/lib/rubocop/config_store.rb:47:in `for_pwd'
/path-to/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubocop-1.34.0/lib/rubocop/cli.rb:99:in `parallel_by_default!'
/path-to/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubocop-1.34.0/lib/rubocop/cli.rb:46:in `run'
/path-to/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubocop-1.34.0/exe/rubocop:19:in `block in <top (required)>'
/path-to/.rbenv/versions/3.1.1/lib/ruby/3.1.0/benchmark.rb:311:in `realtime'
/path-to/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubocop-1.34.0/exe/rubocop:19:in `<top (required)>'
/path-to/.rbenv/versions/3.1.1/bin/rubocop:25:in `load'
/path-to/.rbenv/versions/3.1.1/bin/rubocop:25:in `<main>'
Finished in 0.01386200000001736 seconds
Steps to reproduce the problem
- Just do
%rubocop
RuboCop version
% bundle exec rubocop -V
1.34.0 (using Parser 3.1.2.1, rubocop-ast 1.21.0, running on ruby 3.1.1 arm64-darwin21)
- rubocop-rails 2.15.2
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 5
- Comments: 15 (7 by maintainers)
Commits related to this issue
- [Fix #10893] Fix an error when running `rubocop` without `bundle exec` Fixes #10893. This PR fixes an error when running `rubocop` without `bundle exec`. — committed to koic/rubocop by koic 4 years ago
- [Fix #10893] Fix an error when running `rubocop` without `bundle exec` Fixes #10893. This PR fixes an error when running `rubocop` without `bundle exec`. — committed to rubocop/rubocop by koic 4 years ago
- [Fix #10893] Fix loading behavior on running without `bundle exec` — committed to r7kamura/rubocop by r7kamura 4 years ago
- Merge pull request #10909 from r7kamura/feature/kernel-require [Fix #10893] Fix loading behavior on running without `bundle exec` — committed to rubocop/rubocop by koic 4 years ago
- Add rubocop configo reference: https://github.com/rubocop/rubocop/issues/10893#issuecomment-1952517060 https://docs.rubocop.org/rubocop/usage/server.html#restart-server — committed to paulohenrique-gh/rails-repertoire-manager by paulohenrique-gh 3 years ago
Still getting such error with v1.60.2. I’m adding new rubocop extentions to my
Gemfile(ex. ‘rubocop-rails’) and then to the.rubocop.yml. And when I try to executerubocop- oops! cannot load such file.But! I was able to fix this with
rubocop --restart-server. In the docs I found this: https://docs.rubocop.org/rubocop/usage/server.html#restart-serverFor me @BoutPure 's answer worked
rubocop --restart-serverSame issue with new rubocop-rspec 3.0.1 and rubocop 1.64.1
cannot load such file – rubocop-rspec_rails
.rubocop.yml
Gemfile:
The same error.
JFYI, RuboCop 1.34.1 has been released. Thank you.
@hiro-teaaa OK, It was reproducible. Thank you!
Can confirm this issue. It fails for any require that is placed in the
.rubocop.ymlconfig file, works fine when using the cli argument$ rubocop --require rubocop-rails --require rubocop-performance.This error is caused by #10845. It requires backward compatibility.
+1