Skip to content

Conversation

@pboling
Copy link
Contributor

@pboling pboling commented Jan 5, 2026

Description

This PR adds Ruby 4.1 to the supported version arrays, enabling version-based cfg flags for Ruby head compatibility.

Changes

  1. crates/rb-sys/build/main.rs

    • Added Version::new(4, 1) to SUPPORTED_RUBY_VERSIONS array
    • Updated array size from 11 to 12
  2. crates/rb-sys-env/src/ruby_version.rs

    • Added (4, 0) and (4, 1) to COMPARABLE_RUBY_MINORS array
    • Updated array size from 11 to 13

New cfg flags available

After this change, the following cfg flags will be available when building with Ruby 4.1:

  • ruby_lt_4_1 / ruby_lte_4_1 / ruby_eq_4_1 / ruby_gte_4_1 / ruby_gt_4_1
  • ruby_4_1 / ruby_4_1_0 (etc.)

Motivation

Ruby 4.1 (ruby-head) introduces breaking changes in the Ruby C API that require conditional compilation in dependent crates. Specifically, rb_data_type_struct__bindgen_ty_1 replaced the reserved field with handle_weak_references.

This change enables crates like magnus to properly support both Ruby < 4.1 and Ruby >= 4.1.

Testing

  • Builds successfully with Ruby 4.0.0
  • Enables proper cfg flag detection for Ruby 4.1
  • Backward compatible with all existing supported Ruby versions

Closes #696

Ruby 4.1 (ruby-head) introduces breaking C API changes that require
conditional compilation in dependent crates. This adds 4.1 to the
supported version arrays to enable ruby_lt_4_1, ruby_gte_4_1, and
related cfg flags.

Changes:
- Add Version::new(4, 1) to SUPPORTED_RUBY_VERSIONS in rb-sys
- Add (4, 0) and (4, 1) to COMPARABLE_RUBY_MINORS in rb-sys-env

This enables crates like magnus to handle the rb_data_type_struct
change where 'reserved' was replaced with 'handle_weak_references'.

Closes oxidize-rb#696
Copilot AI review requested due to automatic review settings January 5, 2026 21:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Ruby 4.1 version support to enable compatibility with ruby-head, which introduces breaking changes in the Ruby C API (specifically the replacement of the reserved field with handle_weak_references in rb_data_type_struct__bindgen_ty_1). The changes also fix a previously missing (4, 0) entry in the comparable minors array.

  • Added Ruby 4.1 to supported version arrays in two key modules
  • Fixed missing Ruby 4.0 entry in COMPARABLE_RUBY_MINORS array (synchronization fix)
  • Enables version-based cfg flags for conditional compilation targeting Ruby 4.1

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/rb-sys/build/main.rs Added Version::new(4, 1) to SUPPORTED_RUBY_VERSIONS array and updated array size from 11 to 12
crates/rb-sys-env/src/ruby_version.rs Added (4, 0) and (4, 1) to COMPARABLE_RUBY_MINORS array and updated array size from 11 to 13, fixing previous missing (4, 0) entry

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ianks ianks merged commit 44cb572 into oxidize-rb:main Jan 5, 2026
62 of 63 checks passed
pboling added a commit to pboling/tree_stump that referenced this pull request Jan 6, 2026
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.

Ruby 4.1 (ruby-head) Support

2 participants