Ruby 4.0 support - just needs a new gem release
Hey,
Ruby 4.0.0 was released on Christmas and the current google-protobuf gem (4.33.2) has required_ruby_version set to < 3.5.dev, >= 3.1.
This constraint is baked in at build time for the prebuilt platform gems. The actual code works fine on Ruby 4.0 - the next release pipeline will automatically pick up the correct Ruby version, no code changes needed.
Just waiting on the next release to unblock Ruby 4.0 users.
Thanks!
Any chance for a quick release? 👀 The change looks minor and this would really help
I am currently working on the internal test infrastructure changes needed to support Ruby 4.0. Without it, no tests will actually run under the new version.
Thank you .
Could you add support to ruby-head while you are on it ?
This will allow us (gems maintainers) to test future versions and to not have this gem as a choke point)
Asking to understand: how would a ruby-head test configuration for protobuf be helpful to other gem maintainers? I'm not actually clear how useful it would be to the Protobuf team, given it is inherently non-hermetic, so I'm having a hard time seeing how it helps anyone that has a protobuf dependency... If it breaks, how will we know it's a problem with protobuf vs unreleased changes in ruby?
The issue is that we cannot run ruby-head if the dependent gems are not tested without being in the dark.
If i see that this gem has a red test suite in ruby 4.1.dev, i'm not going to spend time trying to debug on my side.
@seuros - I'm working through some Ruby 4 specific issues, but one that I haven't yet encountered is an upper bound on the Ruby language version. https://rubygems.org/gems/google-protobuf shows only the lower bound (e.g. >= 3.1) is set.
Can you confirm that < 3.5.dev is coming from something outside of the protobuf gem itself?
Note: Ruby 4.0 support is also being tracked in #25051
Yes the lock is not this gem, but from rake-compiler-dock
However the upper lock happen at compile time and gem release.
rake-compiler-dock did add ruby 4.0 support in 1.11.0 / 2025-12-25
The solution is to bump the version and rerelease! The new version of RCD will be fetched and the lock relaxed.
rake-compiler-dock is only a development dependency, and the existing version constraints should allow it float up to 1.11 without changes. On my local, gem install google-protobuf --development results in picking up rake-compiler-dock with version 1.11.1 released on December 27th. Do you get the same?
Yes, that case.
This should be fixed via 93f4eba2585a84ed26c29c6120a6d2ae37b68b60.
The workflow changes appear to be included in 34.0rc1 but it unfortunately does not work and still has an upper bound of < 3.5: https://rubygems.org/gems/google-protobuf/versions/4.34.0.rc.1-arm64-darwin.
I’ll look into what’s going on with binary gems. The source gem does not have an upper bound.
On my local,
gem install google-protobuf --developmentresults in picking uprake-compiler-dockwith version1.11.1released on December 27th.
This is true but the build invokes bundle which will install the specific version referenced in the lockfile:
https://github.com/protocolbuffers/protobuf/blob/bb51fee7eb8f31924bae11029a766af0d772ca6c/ruby/Gemfile.lock#L16
The solution is extremely simple.
bundle update rake-compiler-dock
commit&push and release a patch version.
I used the following, and it works for us
gem 'google-protobuf', force_ruby_platform: true