KEMBAR78
[Fix #14541] Fix gemspec parsing error when parser_prism is configured by sudoremo · Pull Request #14550 · rubocop/rubocop · GitHub
Skip to content

Conversation

@sudoremo
Copy link
Contributor

@sudoremo sudoremo commented Sep 22, 2025

When ParserEngine is set to parser_prism in a base config file and RuboCop needs to parse a gemspec to detect the Ruby version, it was using DEFAULT_VERSION (2.7) which is incompatible with Prism that requires Ruby 3.3+.

This fix ensures that when parser_prism is configured, we use Ruby 3.3 for parsing the gemspec file. The parsing version doesn't affect the detected required_ruby_version - it's only used for the parsing step.

This fixes #14541.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

…nfigured

When ParserEngine is set to parser_prism in a base config file and
RuboCop needs to parse a gemspec to detect the Ruby version, it was
using DEFAULT_VERSION (2.7) which is incompatible with Prism that
requires Ruby 3.3+.

This fix ensures that when parser_prism is configured, we use Ruby 3.3
for parsing the gemspec file. The parsing version doesn't affect the
detected required_ruby_version - it's only used for the parsing step.
@Earlopain
Copy link
Contributor

Thanks for the PR, but I don't think this is the correct solution.

The default that rubocop uses is 2.7, and that should not change with what parser engine is used. In the issue, the user does set 3.3 to be used but it has no effect, so there is something going wrong in config inheritance. That is what should be fixed.

@Earlopain
Copy link
Contributor

Sorry, I did not look closely enough. I understand now why you did it this way. Seems ok to me.

@bbatsov bbatsov merged commit d0bc9e1 into rubocop:master Sep 23, 2025
37 of 38 checks passed
@bbatsov
Copy link
Collaborator

bbatsov commented Sep 23, 2025

Looks good to me. Thanks!

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

Successfully merging this pull request may close these issues.

Specifying parser engine in inherited file breaks with gemspec present

3 participants