Skip to content

Conversation

@kpumuk
Copy link
Contributor

@kpumuk kpumuk commented Nov 19, 2025

base64 in Ruby 3.4

Starting with Ruby 3.4, base64 is no longer a bundled gem, and now Thrift does not load in modern Ruby versions:

An error occurred while loading ./spec/types_spec.rb.

Failure/Error: require 'base64'

LoadError:
  cannot load such file -- base64
# ./lib/thrift/protocol/json_protocol.rb:21:in '<top (required)>'
# ./lib/thrift.rb:45:in '<top (required)>'
# ./spec/spec_helper.rb:30:in '<top (required)>'
# ./spec/types_spec.rb:20:in '<top (required)>'

Ruby already has ability to serialize and deserialize base64 without requiring the base64 gem, which is a thin wrapper for syntactic sugar.

logger in Ruby 3.5

Throws a warning at the moment, and will be an error in Ruby 3.5:

/code/lib/thrift/processor.rb:20: warning: logger was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.
You can add logger to your Gemfile or gemspec to silence this warning.

ostruct in Ruby 3.5 (transitive dependency on Rake 12.x)

Additionally, Rake used to use ostruct, which will be removed in Ruby 4.0, and running tests produced the following warning:

/Users/dmytro/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/rake-12.3.3/lib/rake.rb:33: warning: ostruct was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.

Updated Rake version to get rid of the warning and fix the gem for Ruby 4.0 (formerly known as 3.5)

Important

This is not enough to fix the gem for Ruby 3.5. Thrift currently only works with Rack 2, which also depends on ostruct without explicitly defining it (the usage was removed in Rack 3.1)
Rack 3 support will require additional work.

  • Did you create an Apache Jira ticket? THRIFT-5905
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

@fishy fishy added the ruby label Nov 20, 2025
@kpumuk kpumuk changed the title Added base64 as an explicit dependency Added base64 and logger as explicit dependencies Nov 20, 2025
@kpumuk kpumuk changed the title Added base64 and logger as explicit dependencies THRIFT-5905: Added base64 and logger as explicit dependencies Nov 20, 2025
@kpumuk kpumuk changed the title THRIFT-5905: Added base64 and logger as explicit dependencies THRIFT-5905: Removed base64 and added logger as an explicit add_dependency Nov 22, 2025
Starting with Ruby 3.4, base64 is no longer a bundled gem, and now Thrift does not load in modern Ruby versions:

    An error occurred while loading ./spec/types_spec.rb.

    Failure/Error: require 'base64'

    LoadError:
      cannot load such file -- base64
    # ./lib/thrift/protocol/json_protocol.rb:21:in '<top (required)>'
    # ./lib/thrift.rb:45:in '<top (required)>'
    # ./spec/spec_helper.rb:30:in '<top (required)>'
    # ./spec/types_spec.rb:20:in '<top (required)>'

Ruby already has ability to serialize and deserialize base64 without requiring the base64 gem,
which is a thin wrapper for syntactic sugar.

Additionally, the code throws a warning at the moment, which will become an error in Ruby 3.5:

    /code/lib/thrift/processor.rb:20: warning: logger was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.
    You can add logger to your Gemfile or gemspec to silence this warning.

Added logger as an explicit dependency to avoid this warning.
@kpumuk
Copy link
Contributor Author

kpumuk commented Nov 22, 2025

Rewrote the code to avoid the dependency on "base64".

@kpumuk
Copy link
Contributor Author

kpumuk commented Nov 22, 2025

Ruby specs pass with this change https://github.com/kpumuk/thrift/actions/runs/19598791172

CleanShot 2025-11-22 at 12 32 26@2x

@kpumuk
Copy link
Contributor Author

kpumuk commented Nov 22, 2025

Cross-tests pass as well https://github.com/kpumuk/thrift/actions/runs/19598908804:

CleanShot 2025-11-22 at 12 49 29@2x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants