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

Gem upgrade results in error: uninitialized constant RuboCop::Cop::Rails::RedundantActiveRecordAllMethod::AllowedReceivers #1138

Closed
jessieay opened this issue Oct 5, 2023 · 7 comments

Comments

@jessieay
Copy link

jessieay commented Oct 5, 2023

Be clear, concise and precise in your description of the problem.
Open an issue with a descriptive title and a summary in grammatically correct,
complete sentences.

Use the template below when reporting bugs. Please, make sure that
you're running the latest stable RuboCop and that the problem you're reporting
hasn't been reported (and potentially fixed) already.

Before filing the ticket you should replace all text above the horizontal
rule with your own words.


Expected behavior

I can use rubocop-rails gem without any errors

Actual behavior

I see an error.

Steps to reproduce the problem

Upgrading the latest gem version results in this error:

uninitialized constant RuboCop::Cop::Rails::RedundantActiveRecordAllMethod::AllowedReceivers

/builds/gitlab-org/ruby/gems/declarative-policy/vendor/ruby/3.0.6/ruby/3.0.0/gems/rubocop-rails-2.21.2/lib/rubocop/cop/rails/redundant_active_record_all_method.rb:30:in `<class:RedundantActiveRecordAllMethod>'

I believe this is the result of a recent PR: #1127

I saw this failure in my CI build here: https://gitlab.com/gitlab-org/ruby/gems/declarative-policy/-/merge_requests/56

RuboCop version

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

bundle exec rubocop -v
1.43.0
@koic
Copy link
Member

koic commented Oct 5, 2023

Can you provide the result of bundle exec rubocop -V (or rubocop -V) command? AllowedReceivers module was introduced in RuboCop 1.52. rubocop/rubocop#11909

If you have an older version of RuboCop, updating it with bundle update rubocop might resolve the issue.

@jessieay
Copy link
Author

jessieay commented Oct 5, 2023

Can you provide the result of bundle exec rubocop -V (or rubocop -V) command? AllowedReceivers module was introduced in RuboCop 1.52. rubocop/rubocop#11909

If you have an older version of RuboCop, updating it with bundle update rubocop might resolve the issue.

Great call @koic - we are on rubocop 1.43.0 because of a related dependency / not wanting to drop support for Ruby 2.6. Oversight on my part! Closing

@jessieay jessieay closed this as completed Oct 5, 2023
@Zarthus
Copy link

Zarthus commented Oct 5, 2023

Related issue: #1143

@Zarthus
Copy link

Zarthus commented Oct 5, 2023

@jessieay - I am not sure if we should close this issue - changing minimum required rubocop version in a patch level update is probably a bit unexpected, and the error is also rather ambiguous and not very helpful if you're trying to understand what happened. (also happy to continue in 1143)

@Zarthus
Copy link

Zarthus commented Oct 5, 2023

One way to mitigate this issue is to update https://github.com/rubocop/rubocop-rails/blob/master/rubocop-rails.gemspec#L38 to 1.52.0 -- releasing that change at 2.21.3 should make the error clearer for anyone upgrading. I don't know if yanking is a great idea.

@jessieay
Copy link
Author

jessieay commented Oct 6, 2023

I am not sure if we should close this issue - changing minimum required rubocop version in a patch level update is probably a bit unexpected, and the error is also rather ambiguous and not very helpful if you're trying to understand what happened.

Thanks for weighing im, @Zarthus . I see you've opened #1144. I agree that it is a bit confusing for rubocop-rails to depend on modules included in newer versions of rubocop without updating the gemspec to require those newer versions of rubocop.

@smarquez1
Copy link

Limiting rubocop-rails version to ~> 2.19.0 fixed the issue for me.

Using Rubocop ~> 1.42.0

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

No branches or pull requests

4 participants