Skip to content

Support Ruby 3.0 #524

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

Closed
wants to merge 6 commits into from
Closed

Conversation

andyundso
Copy link
Member

This PR adds support for Ruby 3.0. It needed a couple of changes, including a few that are technically for Ruby 2.5 support.

  • Delete the extra minitest entry in the Gemfile. As explained in the commit, the gemspec locked minitest to v5.14.0, but the version from the Gemfile had higher priority, which meant it installed 5.17.0 which isn't compatible anymore with Ruby 2.5.
  • Lock bundler version on CI to 2.3.16, as this is the last release that supports Ruby 2.5.
  • I tried to build the Windows native gem by running bundle exec rake gem:windows, but this failed with a Rake error that it is unable to find this task. I updated the Rake task in this project to match the example from the rake-compiler-dock docs, which made the build start.
  • I got a very long error message when trying to compile with OpenSSL v1.1.1d, so I updated it to v1.1.1s.
  • And at last, compile the ports and the gem itself against Ruby 3.0.

I tested the changes against a project of mine. It's a "traditional" Rails v6.1 application using 6.1.2.1. I ran our CI with a version of the gem build based on my changes and everything is green with the following combinations:

  • Ruby 2.7, x64-mingw32, SQL Server Express 2017
  • Ruby 3.0, x64-mingw32, SQL Server Express 2017
  • Ruby 2.7, x86_64-linux, FreeTDS v1.2.20, SQL Server Express 2017
  • Ruby 2.7, x86_64-linux, FreeTDS v1.2.20, SQL Server Express 2019
  • Ruby 3.0, x86_64-linux, FreeTDS v1.2.20, SQL Server Express 2017
  • Ruby 3.0, x86_64-linux, FreeTDS v1.2.20, SQL Server Express 2019

Credits to @bryanwieg for the initial work in #521.

When running `bundle install`, it tried to install the latest minitest version, as it was defined again in the Gemfile. This caused issues with Ruby 2.5, as support for it was dropped in v5.16.0.

Removing this extra code makes bundler correctly install 5.14.0 as defined in the gemspec.
This is the last release that supports Ruby 2.5.
1.1.1d threw error messages, but compiling against 1.1.1s seems to work.
@bryanwieg
Copy link
Contributor

@andyundso this looks really nice!

@aharpervc will probably be the one to review it.


RakeCompilerDock.sh build.join(' && ')
GEM_PLATFORM_HOSTS.keys.each do |plat|
RakeCompilerDock.sh "bundle --local && RUBY_CC_VERSION='2.7.0:2.6.0:2.5.0:2.4.0' CFLAGS='-Wall' MAKE='make -j`nproc`' rake native:#{plat} gem", platform: plat
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This command switched from rake cross native gem to rake native:{plat}. Why does this need to change?
  2. I see we have Ruby 2.4 on the cross compile list. Given the other commit about bundler (etc), and that Ruby 2.4 is well out of support, what do you think about dropping it? That'd mean that our current release is the last one tested on 2.4. We have the same questions about 2.5 and 2.6, although those ought to continue to work for the time being, so I don't think we also need to drop those right now.

OPENSSL_VERSION = ENV['TINYTDS_OPENSSL_VERSION'] || '1.1.1d'
OPENSSL_VERSION = ENV['TINYTDS_OPENSSL_VERSION'] || '1.1.1s'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is fine. Are the 1.1.1 release variants cross compatible with each other? Is there any downside to moving as far forward as the latest l (L) release?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, l doesn't refer to latest, they're just going through the alphabet on releases for 1.1.1, and s is the most recent at the moment

RakeCompilerDock.sh "bundle --local && RUBY_CC_VERSION='2.7.0:2.6.0:2.5.0:2.4.0' CFLAGS='-Wall' MAKE='make -j`nproc`' rake native:#{plat} gem", platform: plat
RakeCompilerDock.sh "bundle --local && RUBY_CC_VERSION=#{RUBY_CC_VERSION} CFLAGS='-Wall' MAKE='make -j`nproc`' rake native:#{plat} gem", platform: plat
Copy link
Contributor

@aharpervc aharpervc Jan 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind moving this to a separate commit, such that adding 3.0 to the list only adds 3.0 and no other code changes (adding to the changelog can also be in this commit)?

My thinking here is to help others understand what the commit should look like going forward for other versions.

build = ['bundle']
sh "bundle package --all" # Avoid repeated downloads of gems by using gem files from the host.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the similar lines in ports.rake (etc) also be changed?

@aharpervc
Copy link
Contributor

aharpervc commented Jan 9, 2023

This is cool... very exciting. Are you able to also do any of the suggestions here? At least having build artifacts for this would be great to get more people for testing.

@andyundso andyundso mentioned this pull request Jan 11, 2023
@andreasnef
Copy link

Would be great to get this as I assume many (as us) are planning moving to v3 soon.

@orgads
Copy link
Contributor

orgads commented Mar 26, 2023

Please add also 3.1 and 3.2.

@andyundso
Copy link
Member Author

As long as things are still moving here, I created a fork with support for Ruby 3.0, 3.1 and 3.2, including a fat gem for Windows.

@orgads
Copy link
Contributor

orgads commented Mar 28, 2023

Thank you!

@andyundso
Copy link
Member Author

Replaced with #530.

@andyundso andyundso closed this Apr 2, 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.

6 participants