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:
Run test cases in box to protect other tests when the test case uses monkey patches to override something
Run web app boxes in parallel to execute blue-green deployment on an app server in a Ruby process
Run web app boxes in parallel to evaluate dependency updates for a certain period of time by checking response diff using Ruby code
Used as the foundation (low-level) API to implement kind of “package” (high-level) API (it is not designed yet)
... continue reading