Back Original

Ruby 4.0.0

Posted by naruse on 25 Dec 2025

We are pleased to announce the release of Ruby 4.0.0. Ruby 4.0 introduces “Ruby Box” and “ZJIT”, and adds many improvements.

Ruby Box

Ruby Box is a new (experimental) feature to provide separation about definitions. Ruby Box is enabled when an environment variable RUBY_BOX=1 is specified. The class is Ruby::Box.

Definitions loaded in a box are isolated in the box. Ruby Box can isolate/separate monkey patches, changes of global/class variables, class/module definitions, and loaded native/ruby libraries from other boxes.

Expected use cases are:

For the detail of “Ruby Box”, see Ruby::Box. [Feature #21311] [Misc #21385]

ZJIT

ZJIT is a new just-in-time (JIT) compiler, which is developed as the next generation of YJIT. You need Rust 1.85.0 or newer to build Ruby with ZJIT support, and ZJIT is enabled when --zjit is specified.

We’re building a new compiler for Ruby because we want to both raise the performance ceiling (bigger compilation unit size and SSA IR) and encourage more outside contribution (by becoming a more traditional method compiler). See our blog post for more details.

ZJIT is faster than the interpreter, but not yet as fast as YJIT. We encourage you to experiment with ZJIT, but maybe hold off on deploying it in production for now. Stay tuned for Ruby 4.1 ZJIT.

Ractor Improvements

Ractor, Ruby’s parallel execution mechanism, has received several improvements. A new class, Ractor::Port, was introduced to address issues related to message sending and receiving (see our blog post). Additionally, Ractor.shareable_proc makes it easier to share Proc objects between Ractors.

On the performance side, many internal data structures have been improved to significantly reduce contention on a global lock, unlocking better parallelism. Ractors also now share less internal data, resulting in less CPU cache contention when running in parallel.

Ractor was first introduced in Ruby 3.0 as an experimental feature. We aim to remove its “experimental” status next year.

Language changes

Core classes updates

Note: We’re only listing outstanding class updates.

Stdlib updates

We only list stdlib changes that are notable feature changes.

Other changes are listed in the following sections. We also listed release history from the previous bundled version that is Ruby 3.4.0 if it has GitHub releases.

The following bundled gems are promoted from default gems.

The following default gem is added.

The following default gems are updated.

The following bundled gems are updated.

RubyGems and Bundler

Ruby 4.0 bundled RubyGems and Bundler version 4. see the following links for details.

Supported platforms

Compatibility issues

Stdlib compatibility issues

C API updates

Implementation improvements

Ractor

A lot of work has gone into making Ractors more stable, performant, and usable. These improvements bring Ractor implementation closer to leaving experimental status.

JIT

See NEWS or commit logs for more details.

With those changes, 3889 files changed, 230769 insertions(+), 297003 deletions(-) since Ruby 3.4.0!

Merry Christmas, a Happy New Year, and Happy Hacking with Ruby 4.0!

Download

What is Ruby

Ruby was first developed by Matz (Yukihiro Matsumoto) in 1993, and is now developed as Open Source. It runs on multiple platforms and is used all over the world especially for web development.