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 Ruby 3.0 support #16046

Merged
merged 9 commits into from May 6, 2021
Merged

Conversation

ClearlyClaire
Copy link
Contributor

@ClearlyClaire ClearlyClaire commented Apr 16, 2021

  • monkey-patch Terrapin and Cocaine to work around an issue with posix-spawn executing the child process with non-blocking file descriptors for stdout and stderr when using Ruby 3.0 (also fixed another issue not related to Ruby 3.0)
  • monkey-patch Paperclip to fix usage of keyword arguments (in the future, looking at https://github.com/kreeti/kt-paperclip may be a better choice, but we currently depend on behavior from 6.0.0 that is changed in more recent releases)
  • change keyword argument handling here and there

Actually running it on Ruby 3.0 is still not possible after that PR because one dependency (microformats) does not advertise Ruby 3.0 compatibility.

@ClearlyClaire ClearlyClaire force-pushed the fixes/prepare-ruby-3.0 branch 6 times, most recently from 6fa9112 to 847d698 Compare April 16, 2021 19:07
@ClearlyClaire ClearlyClaire marked this pull request as ready for review April 16, 2021 19:31
@ClearlyClaire
Copy link
Contributor Author

Reading on the IO.select warning from DeepSource:

IO.select statements can get very hard to make them compatible with Ruby 3 scheduler. It is recommended to use wait_readable or wait_writable on an IO object with a given timeout instead of rescuing an IO::WaitReadable or IO::WaitWritable error and using IO.select in the block.

I think it's a bit early to really bother for now. As far as I understand, the idea is that Ruby's scheduler will eventually be able to schedule fibers, automatically yielding control to another fiber whenever hitting a supported IO operation, which read and wait_readable may be. However, I don't think this is fully implemented yet, and we do not make explicit use of fibers anyway.

I assume a good replacement to the pattern I used would eventually be to use fibers ourselves and have Ruby deal with them, but for now, I think it is fine using IO.select.

@ClearlyClaire ClearlyClaire changed the title Prepare Mastodon for Ruby 3.0 Add Ruby 3.0 support May 3, 2021
@ClearlyClaire ClearlyClaire force-pushed the fixes/prepare-ruby-3.0 branch 2 times, most recently from e1a05e9 to 62b6b25 Compare May 3, 2021 19:58
@Gargron Gargron merged commit 566fc90 into mastodon:main May 6, 2021
@tyteen4a03
Copy link

Late to the party, but a fresh install of 3.4.1 with a modified .ruby_version of 3.0.2 doesn't work out of the box.

I had to add rexml Gem (which apparently is no longer shipped by default in 3.0)

chrisguida pushed a commit to Start9Labs/mastodon that referenced this pull request Feb 26, 2022
* Fix issues with POSIX::Spawn, Terrapin and Ruby 3.0

Also improve the Terrapin monkey-patch for the stderr/stdout issue.

* Fix keyword argument handling throughout the codebase

* Monkey-patch Paperclip to fix keyword arguments handling in validators

* Change validation_extensions to please CodeClimate

* Bump microformats from 4.2.1 to 4.3.1

* Allow Ruby 3.0

* Add Ruby 3.0 test target to CircleCI

* Add test for admin dashboard warnings

* Fix admin dashboard warnings on Ruby 3.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

Successfully merging this pull request may close these issues.

None yet

3 participants