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

Add support for Ruby 3.1 #1474

Merged
merged 1 commit into from
Aug 5, 2022
Merged

Add support for Ruby 3.1 #1474

merged 1 commit into from
Aug 5, 2022

Conversation

vsppedro
Copy link
Collaborator

@vsppedro vsppedro commented Jan 10, 2022

🚀

@aried3r
Copy link

aried3r commented Jan 24, 2022

I believe the test failures you're seeing here are because only Rails 7.0.1 and above officially support Ruby 3.1, see: https://gist.github.com/yahonda/2776d8d7b6ea7045359f38c10449937b. 6.1 can work, but doesn't in this case (yet?), see: rails/rails#44090.

@technicalpickles
Copy link
Contributor

https://gist.github.com/yahonda/2776d8d7b6ea7045359f38c10449937b

Does adding gem "psych", "~> 3.0" to appraisals help with the psych errors? It's odd to see this on the 6.1 branch

Rails 6.0.Z
You will likely get this error.
Psych::BadAlias: Unknown alias: default

We are on 6.1.4, but there are some (whatever is less than patch) revisions up to 6.1.4.4. Maybe those will help?

@vsppedro vsppedro force-pushed the update-ruby branch 2 times, most recently from 9da0994 to 0745f02 Compare February 1, 2022 13:20
@vsppedro
Copy link
Collaborator Author

vsppedro commented Feb 1, 2022

It will be necessary to update rubocop and fix all the offenses before continuing with this PR. Thank you so much for the help, @technicalpickles, and @aried3r! ❤️

I will work on that ASAP!

@vsppedro vsppedro force-pushed the update-ruby branch 7 times, most recently from 75e444f to 01fe2a8 Compare August 5, 2022 04:21
@vsppedro
Copy link
Collaborator Author

vsppedro commented Aug 5, 2022

Finally! 🚀

There were two problems preventing this update:

Rubocop is showing some bugs when running with Ruby 3.1:

Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
Inspecting 274 files
.......................................................................................................................................................................................................An error occurred while Layout/BlockAlignment cop was inspecting /home/pedro/tempo-livre/collaborator/shoulda-matchers/spec/support/unit/i18n.rb:1:0.
To see the complete backtrace run rubocop -d.
....................An error occurred while Layout/BlockAlignment cop was inspecting /home/pedro/tempo-livre/collaborator/shoulda-matchers/spec/support/unit/shared_examples/ignoring_interference_by_writer.rb:1:0.
To see the complete backtrace run rubocop -d.
.An error occurred while Layout/BlockAlignment cop was inspecting /home/pedro/tempo-livre/collaborator/shoulda-matchers/spec/support/unit/shared_examples/numerical_submatcher.rb:1:0.
To see the complete backtrace run rubocop -d.
.An error occurred while Layout/BlockAlignment cop was inspecting /home/pedro/tempo-livre/collaborator/shoulda-matchers/spec/support/unit/shared_examples/set_session_or_flash.rb:1:0.
To see the complete backtrace run rubocop -d.
.....................................................

274 files inspected, no offenses detected

4 errors occurred:
An error occurred while Layout/BlockAlignment cop was inspecting /home/pedro/tempo-livre/collaborator/shoulda-matchers/spec/support/unit/i18n.rb:1:0.
An error occurred while Layout/BlockAlignment cop was inspecting /home/pedro/tempo-livre/collaborator/shoulda-matchers/spec/support/unit/shared_examples/ignoring_interference_by_writer.rb:1:0.
An error occurred while Layout/BlockAlignment cop was inspecting /home/pedro/tempo-livre/collaborator/shoulda-matchers/spec/support/unit/shared_examples/numerical_submatcher.rb:1:0.
An error occurred while Layout/BlockAlignment cop was inspecting /home/pedro/tempo-livre/collaborator/shoulda-matchers/spec/support/unit/shared_examples/set_session_or_flash.rb:1:0.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop-hq/rubocop/issues

Mention the following information in the issue report:
1.0.0 (using Parser 2.7.2.0, rubocop-ast 1.1.0, running on ruby 3.1.2 x86_64-linux)

That's why I didn't change the ruby ​​version in the .ruby-verion and .tool- versions. I'll work on that in another PR. I think it's necessary to update rubocop.

@mcmire, what do you think?

@vsppedro vsppedro requested a review from mcmire August 5, 2022 04:48
@mcmire
Copy link
Collaborator

mcmire commented Aug 5, 2022

Yeah something is definitely fishy here. I feel like it's probably been a while since we've updated Rubocop so it sounds like updating could work.

@vsppedro
Copy link
Collaborator Author

vsppedro commented Aug 5, 2022

I tried to update rubocop, but another error appeared. It looks like it won't be that simple. I will focus on creating a new release for shoulda-matchers adding support for ruby ​​3.1 and Rails 7. After that, I will update rubocop or create an issue in case someone else wants to make this contribution.

@vsppedro vsppedro merged commit e965a27 into main Aug 5, 2022
@vsppedro vsppedro deleted the update-ruby branch August 5, 2022 17:56
@voxik
Copy link
Contributor

voxik commented Aug 11, 2022

* [Unknown alias: default (Psych::BadAlias)](https://stackoverflow.com/questions/71191685/visit-psych-nodes-alias-unknown-alias-default-psychbadalias). To fix this one was necessary to update rails_6_1 and rails_6_0 with  gem 'psych', '< 4'.

I am just trying shoulda-matchers with Rails 7.0 and the workaround (given that we don't have Psych 3.x on Fedora) is:

sed -i '/def load_file/,/end/ s/::load_file/::unsafe_load_file/' spec/support/tests/database_configuration.rb

I think that the proper solution would be to adjust the #load_file to whatever Rails does on the same place.

@vsppedro
Copy link
Collaborator Author

@voxik, nice catch!

I think I'll have time to make some tests this weekend, thanks for sharing this.

@vsppedro vsppedro mentioned this pull request Sep 15, 2022
@vsppedro vsppedro mentioned this pull request Jan 1, 2023
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.

5 participants