Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError: undefined method `Rainbow' for #<RuboCop::RakeTask ...> #10780

Closed
lopopolo opened this issue Jul 2, 2022 · 3 comments
Closed
Labels

Comments

@lopopolo
Copy link

lopopolo commented Jul 2, 2022

Invoking autocorrect via the RuboCop rake task gives a NoMethodError.


Expected behavior

bundle exec rake lint:rubocop:auto_correct (which invokes the native RuboCop rake task) completes without error.

Actual behavior

This error only reproduces in the rake task, both when there are violations and when there are not.

$ bundle exec rake lint:rubocop:auto_correct --trace
** Invoke lint:rubocop:auto_correct (first_time)
** Execute lint:rubocop:auto_correct
rake aborted!
NoMethodError: undefined method `Rainbow' for #<RuboCop::RakeTask:0x000000010c82ead0 @name=:rubocop, @verbose=true, @fail_on_error=true, @patterns=[], @requires=[], @options=[], @formatters=[]>

          warn Rainbow(
               ^^^^^^^
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rubocop-1.31.1/lib/rubocop/rake_task.rb:76:in `block (2 levels) in setup_subtasks'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/usr/local/var/rbenv/versions/3.1.2/bin/rake:25:in `load'
/usr/local/var/rbenv/versions/3.1.2/bin/rake:25:in `<top (required)>'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/3.1.0/bundler/cli/exec.rb:58:in `load'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/3.1.0/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/3.1.0/bundler/cli/exec.rb:23:in `run'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/3.1.0/bundler/cli.rb:484:in `exec'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/3.1.0/bundler/cli.rb:31:in `dispatch'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/3.1.0/bundler/cli.rb:25:in `start'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.7/libexec/bundle:48:in `block in <top (required)>'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/3.1.0/bundler/friendly_errors.rb:103:in `with_friendly_errors'
/usr/local/var/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.7/libexec/bundle:36:in `<top (required)>'
/usr/local/var/rbenv/versions/3.1.2/bin/bundle:25:in `load'
/usr/local/var/rbenv/versions/3.1.2/bin/bundle:25:in `<main>'
Tasks: TOP => lint:rubocop:auto_correct

Steps to reproduce the problem

This is extremely important! Providing us with a reliable way to reproduce
a problem will expedite its solution.

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler.
If you see extension cop versions (e.g. rubocop-performance, rubocop-rspec, and others)
output by rubocop -V, include them as well. Here's an example:

$ bundle exec rubocop -V
1.31.1 (using Parser 3.1.2.0, rubocop-ast 1.18.0, running on ruby 3.1.2 x86_64-darwin21)
  - rubocop-rake 0.6.0
@lopopolo
Copy link
Author

lopopolo commented Jul 2, 2022

I see this rake task was deprecated in #10746 and it looks like the no method error is coming from the warning that is supposed to tell me that 😅

I think maybe this breakage was introduced in #10709?

@lopopolo
Copy link
Author

lopopolo commented Jul 2, 2022

I just double checked and all of these work, including the new commands so I have a work around:

$ bundle exec rake lint:rubocop
$ bundle exec rake lint:rubocop:autocorrect
$ bundle exec rake lint:rubocop:autocorrect_all

@koic koic added the bug label Jul 2, 2022
@koic koic closed this as completed in 9ebb61a Jul 2, 2022
@koic
Copy link
Member

koic commented Jul 2, 2022

@lopopolo Thank you for the feedback. This issue fixed by 9ebb61a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants