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

Upgrade Ruby to version 3.1.4 #5157

Merged
merged 5 commits into from
Sep 12, 2023
Merged

Upgrade Ruby to version 3.1.4 #5157

merged 5 commits into from
Sep 12, 2023

Conversation

javierm
Copy link
Member

@javierm javierm commented Jul 22, 2023

References

Objectives

  • Make it easier to install Consul on distributions using SSL 3
  • Update Ruby to a more recent version

Notes

I've tried to replace the byebug gem with the debug gem that is now included in Ruby 3.1, but GitHub Actions hangs (or takes forever to run the tests) when doing so. Since it hangs on the job running the machine learning model tests, and the message DEBUGGER: Attaching after process X fork to child process Y appears in this case, it might be related to the fact that the debugger gem attaches to the processes created by the Process.fork method, which is called in the machine learning tests.

@javierm javierm self-assigned this Jul 22, 2023
@javierm javierm added this to Reviewing in Consul Democracy via automation Jul 22, 2023
@javierm javierm marked this pull request as draft July 22, 2023 21:27
@javierm javierm changed the base branch from master to rails_6.1 July 22, 2023 21:48
@javierm javierm moved this from Reviewing to Doing in Consul Democracy Jul 22, 2023
@javierm javierm force-pushed the ruby3.1 branch 3 times, most recently from 353d4e3 to 3fad249 Compare September 6, 2023 11:07
@javierm javierm force-pushed the rails_6.1 branch 2 times, most recently from 9c79657 to 405f6c4 Compare September 7, 2023 19:53
@javierm javierm moved this from Doing to Reviewing in Consul Democracy Sep 7, 2023
@javierm javierm marked this pull request as ready for review September 7, 2023 19:57
@taitus taitus self-assigned this Sep 12, 2023
Base automatically changed from rails_6.1 to master September 12, 2023 12:48
Note we updated the `mail` gem in commit 1037428, which is necesary
for Ruby 3.1 because it adds the net-smtp dependency. The net-smtp
library was removed from Ruby in Ruby 3.1, and if we don't include it,
we get an error:

```
cannot load such file -- net/smtp (LoadError)
```

We're also updating the Bundler version in the Gemfile.lock so it's the
one included in Ruby 3.1. Without updating it, we get a warning:

```
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)'
has been deprecated. Please call `DidYouMean.correct_error(error_nam e,
spell_checker)' instead.
```

Finally, in order to make Capistrano work, we need to add a couple more
changes:

* Make the net-ssh gem compatible with SSL 3.0; done in commit b2eec08
* Explicitly allow aliases in the `deploy-secrets.yml` file because
  Psych 4.x (included in Ruby 3.1) doesn't load aliases without this
  option
Ruby 3.1 adds the option for hash shortcuts, so it's possible to write
`{ user: , poll: }` instead of `{ user: user, poll: poll }`.

By default, Rubocop expects the new syntax in Ruby 3.1. While right now
I absolutely hate this new syntax, we're allowing both the old and the
new styles because we might start adopting it once we get used to it.
This syntax has been added in Ruby 3.1.

Not using a variable name might not be very descriptive, but it's just
as descriptive as using "block" as a variable name. Using just `&` we
get the same amount of information than using `&block`: that we're
passing a block.

We're still using `&action` in `around_action` methods because here we
aren't using a generic name for the variable, so (at least for now) we
aren't running this cop on controllers using `around_action`.
The `intersect?` method has been added in Ruby 3.1, and it's more
readable than `(a & b).any?`.
We added this option in commit d17b252, but Bundler now keeps
descriptors by default. While this behavior was backported to Ruby
3.0.x, we're changing it now because, we've only noticed it now that
we're upgrading to Ruby 3.1.x, since it was first developed for that
version [1].

[1] rubygems/rubygems@88b7a3e7e2
Consul Democracy automation moved this from Reviewing to Testing Sep 12, 2023
@javierm javierm merged commit cd7cec7 into master Sep 12, 2023
13 checks passed
Consul Democracy automation moved this from Testing to Release 2.1.0 Sep 12, 2023
@javierm javierm deleted the ruby3.1 branch September 12, 2023 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants