From: "hsbt (Hiroshi SHIBATA) via ruby-core" Date: 2026-08-30T23:20:52+00:00 Subject: [ruby-core:126548] [Ruby Bug#21830] Ruby::Box and Kernel#require Issue #21830 has been updated by hsbt (Hiroshi SHIBATA). Status changed from Open to Closed @fxn Thank you for your following up. I merged https://github.com/ruby/ruby/pull/18534, so `rails s` is now working with `RUBY_BOX=1`. I'm traking the support status of RubyGems and Ruby::Box at https://bugs.ruby-lang.org/issues/22275 ---------------------------------------- Bug #21830: Ruby::Box and Kernel#require https://bugs.ruby-lang.org/issues/21830#change-118734 * Author: fxn (Xavier Noria) * Status: Closed * Assignee: tagomoris (Satoshi Tagomori) * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- If you enable `Ruby::Box`, decorations to `Kernel#require` do not work. For example, given _foo.rb_: ```ruby module M def require(_path) puts 'decorated' super end end Kernel.prepend(M) p require 'tsort' ``` the decoration works normally: ``` % ruby -v foo.rb ruby 4.0.0 (2025-12-25 revision 553f1675f3) +YJIT +PRISM [arm64-darwin25] decorated true ``` but it does not with the feature enabled: ``` % RUBY_BOX=1 ruby -v foo.rb ruby 4.0.0 (2025-12-25 revision 553f1675f3) +YJIT +PRISM [arm64-darwin25] ruby: warning: Ruby::Box is experimental, and the behavior may change in the future! See https://docs.ruby-lang.org/en/4.0/Ruby/Box.html for known issues, etc. true ``` With this, Zeitwerk cannot work because it totally depends on a decoration of `Kernel#require` (done [here](https://github.com/fxn/zeitwerk/blob/main/lib/zeitwerk/core_ext/kernel.rb)). Bootsnap also depends on the ability of decorating `Kernel#require` (done [here](https://github.com/rails/bootsnap/blob/main/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb)). On one hand, these gems are walking a fine line in the border of the public interface of Ruby. On the other hand, it is a goal of boxes to be transparent to the code being loaded under them. @tagomoris (Satoshi Tagomori) what should be the way to go in your opinion? /cc @byroot (Jean Boussier) -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/