Skip to content

Support Ruby 4.0 by upgrading magnus to 0.8#34

Open
mlarraz wants to merge 1 commit intonjaremko:mainfrom
mlarraz:ruby-4.0-support
Open

Support Ruby 4.0 by upgrading magnus to 0.8#34
mlarraz wants to merge 1 commit intonjaremko:mainfrom
mlarraz:ruby-4.0-support

Conversation

@mlarraz
Copy link

@mlarraz mlarraz commented Mar 10, 2026

Summary

Ruby 4.0 removed the typed_flag field from RTypedData (see ruby/ruby@ce51ef30), which causes compilation failures with magnus 0.7.x:

error[E0609]: no field `typed_flag` on type `&rb_sys::RTypedData`
   --> magnus-0.7.1/src/r_typed_data.rs:202:58

This PR upgrades magnus from 0.7 to 0.8, which includes the fix (see matsadler/magnus#147).

Changes

  • Bump magnus from 0.7 to 0.8 in both ext/parquet/Cargo.toml and ext/parquet-ruby-adapter/Cargo.toml
  • Enable old-api feature to maintain compatibility with existing code that uses associated functions like RArray::new(), RHash::new(), Symbol::new() (deprecated in 0.8, not removed)
  • Refactor StringCache to use Rust-side deduplication (HashSet<Arc<str>>) instead of Ruby VM interning via FString, which was removed in magnus 0.8 as it could not safely guarantee interned strings wouldn't be garbage collected
  • Bump rb-sys from 0.9.116 to 0.9.124 for Ruby 4.0 bindings support

Testing

Verified the Rust extension compiles successfully against Ruby 4.0.1 on arm64-darwin.

Test plan

  • cargo build --release compiles cleanly on Ruby 4.0.1
  • Existing test suite passes on Ruby 3.x (backwards compatible — magnus 0.8 supports Ruby 2.6+)
  • Existing test suite passes on Ruby 4.0

Ruby 4.0 removed the `typed_flag` field from `RTypedData`, which breaks
magnus 0.7.x compilation. Upgrade to magnus 0.8.2 which has the fix.

Changes:
- Bump magnus from 0.7 to 0.8 in both ext/parquet and
  ext/parquet-ruby-adapter Cargo.toml files
- Enable `old-api` feature to maintain compatibility with existing code
  that uses associated functions like `RArray::new()`, `RHash::new()`
- Refactor StringCache to use Rust-side deduplication (HashSet<Arc<str>>)
  instead of Ruby VM interning via FString, which was removed in
  magnus 0.8 as it could not safely guarantee interned strings wouldn't
  be garbage collected
- Bump rb-sys from 0.9.116 to 0.9.124 for Ruby 4.0 bindings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant