From 430b28d05dc49defdb45552be8f8a7e109fd13ea Mon Sep 17 00:00:00 2001 From: "Peter H. Boling" Date: Mon, 5 Jan 2026 14:48:26 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20Ruby=204.1=20version?= =?UTF-8?q?=20support=20for=20ruby-head=20compatibility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 #696 --- crates/rb-sys-env/src/ruby_version.rs | 4 +++- crates/rb-sys/build/main.rs | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/rb-sys-env/src/ruby_version.rs b/crates/rb-sys-env/src/ruby_version.rs index 9d30dccad..43a330ea4 100644 --- a/crates/rb-sys-env/src/ruby_version.rs +++ b/crates/rb-sys-env/src/ruby_version.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; const COMPARABLE_RUBY_MAJORS: [u8; 4] = [1, 2, 3, 4]; -const COMPARABLE_RUBY_MINORS: [(u8, u8); 11] = [ +const COMPARABLE_RUBY_MINORS: [(u8, u8); 13] = [ (2, 2), (2, 3), (2, 4), @@ -14,6 +14,8 @@ const COMPARABLE_RUBY_MINORS: [(u8, u8); 11] = [ (3, 2), (3, 3), (3, 4), + (4, 0), + (4, 1), ]; /// The current Ruby version. diff --git a/crates/rb-sys/build/main.rs b/crates/rb-sys/build/main.rs index e95e6885e..9eb4f77d6 100644 --- a/crates/rb-sys/build/main.rs +++ b/crates/rb-sys/build/main.rs @@ -13,7 +13,7 @@ use std::{ }; use version::Version; -const SUPPORTED_RUBY_VERSIONS: [Version; 11] = [ +const SUPPORTED_RUBY_VERSIONS: [Version; 12] = [ Version::new(2, 3), Version::new(2, 4), Version::new(2, 5), @@ -25,6 +25,7 @@ const SUPPORTED_RUBY_VERSIONS: [Version; 11] = [ Version::new(3, 3), Version::new(3, 4), Version::new(4, 0), + Version::new(4, 1), ]; fn main() {