ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:124461] [Ruby Bug#21830] Ruby::Box and Kernel#require
@ 2026-01-09  9:48 fxn (Xavier Noria) via ruby-core
  2026-01-09  9:56 ` [ruby-core:124462] " fxn (Xavier Noria) via ruby-core
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: fxn (Xavier Noria) via ruby-core @ 2026-01-09  9:48 UTC (permalink / raw)
  To: ruby-core; +Cc: fxn (Xavier Noria)

Issue #21830 has been reported by fxn (Xavier Noria).

----------------------------------------
Bug #21830: Ruby::Box and Kernel#require
https://bugs.ruby-lang.org/issues/21830

* Author: fxn (Xavier Noria)
* Status: Open
* 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
# foo.rb

% cat foo.rb
module M
  def require(_path)
    puts "decorated"
    super
  end
end

Kernel.prepend(M)

require 'tsort'
```

the decoration works normally:

```
% ruby -v foo.rb
ruby 4.0.0 (2025-12-25 revision 553f1675f3) +YJIT +PRISM [arm64-darwin25]
decorated
```

and the same code does not work 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.
```

With this, Zeitwerk cannot work because it totally depends on `Kernel#require` decoration (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 what should be the way to go in your opinion?

/cc @byroot



-- 
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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:124462] [Ruby Bug#21830] Ruby::Box and Kernel#require
  2026-01-09  9:48 [ruby-core:124461] [Ruby Bug#21830] Ruby::Box and Kernel#require fxn (Xavier Noria) via ruby-core
@ 2026-01-09  9:56 ` fxn (Xavier Noria) via ruby-core
  2026-01-09 14:07 ` [ruby-core:124463] " fxn (Xavier Noria) via ruby-core
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: fxn (Xavier Noria) via ruby-core @ 2026-01-09  9:56 UTC (permalink / raw)
  To: ruby-core; +Cc: fxn (Xavier Noria)

Issue #21830 has been updated by fxn (Xavier Noria).


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 the same code does not work 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)

----------------------------------------
Bug #21830: Ruby::Box and Kernel#require
https://bugs.ruby-lang.org/issues/21830#change-116012

* Author: fxn (Xavier Noria)
* Status: Open
* 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
# foo.rb

% cat foo.rb
module M
  def require(_path)
    puts "decorated"
    super
  end
end

Kernel.prepend(M)

require 'tsort'
```

the decoration works normally:

```
% ruby -v foo.rb
ruby 4.0.0 (2025-12-25 revision 553f1675f3) +YJIT +PRISM [arm64-darwin25]
decorated
```

and the same code does not work 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.
```

With this, Zeitwerk cannot work because it totally depends on `Kernel#require` decoration (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 what should be the way to go in your opinion?

/cc @byroot



-- 
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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:124463] [Ruby Bug#21830] Ruby::Box and Kernel#require
  2026-01-09  9:48 [ruby-core:124461] [Ruby Bug#21830] Ruby::Box and Kernel#require fxn (Xavier Noria) via ruby-core
  2026-01-09  9:56 ` [ruby-core:124462] " fxn (Xavier Noria) via ruby-core
@ 2026-01-09 14:07 ` fxn (Xavier Noria) via ruby-core
  2026-01-11  8:09 ` [ruby-core:124473] " tagomoris (Satoshi Tagomori) via ruby-core
  2026-02-15  8:13 ` [ruby-core:124827] " tagomoris (Satoshi Tagomori) via ruby-core
  3 siblings, 0 replies; 5+ messages in thread
From: fxn (Xavier Noria) via ruby-core @ 2026-01-09 14:07 UTC (permalink / raw)
  To: ruby-core; +Cc: fxn (Xavier Noria)

Issue #21830 has been updated by fxn (Xavier Noria).


Let me add that is also assumed that `Module#autoload` invokes `Kernel#require` as introduced in [cd465d5](https://github.com/ruby/ruby/commit/cd465d552c3a00341f4cb7f1d7a793d0ebcb6cde)

Zeitwerk relies on this too, because the main intercepted `require` calls are coming from autoloads set by autoloaders.

----------------------------------------
Bug #21830: Ruby::Box and Kernel#require
https://bugs.ruby-lang.org/issues/21830#change-116014

* Author: fxn (Xavier Noria)
* Status: Open
* 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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:124473] [Ruby Bug#21830] Ruby::Box and Kernel#require
  2026-01-09  9:48 [ruby-core:124461] [Ruby Bug#21830] Ruby::Box and Kernel#require fxn (Xavier Noria) via ruby-core
  2026-01-09  9:56 ` [ruby-core:124462] " fxn (Xavier Noria) via ruby-core
  2026-01-09 14:07 ` [ruby-core:124463] " fxn (Xavier Noria) via ruby-core
@ 2026-01-11  8:09 ` tagomoris (Satoshi Tagomori) via ruby-core
  2026-02-15  8:13 ` [ruby-core:124827] " tagomoris (Satoshi Tagomori) via ruby-core
  3 siblings, 0 replies; 5+ messages in thread
From: tagomoris (Satoshi Tagomori) via ruby-core @ 2026-01-11  8:09 UTC (permalink / raw)
  To: ruby-core; +Cc: tagomoris (Satoshi Tagomori)

Issue #21830 has been updated by tagomoris (Satoshi Tagomori).

Assignee set to tagomoris (Satoshi Tagomori)

----------------------------------------
Bug #21830: Ruby::Box and Kernel#require
https://bugs.ruby-lang.org/issues/21830#change-116024

* Author: fxn (Xavier Noria)
* Status: Open
* 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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:124827] [Ruby Bug#21830] Ruby::Box and Kernel#require
  2026-01-09  9:48 [ruby-core:124461] [Ruby Bug#21830] Ruby::Box and Kernel#require fxn (Xavier Noria) via ruby-core
                   ` (2 preceding siblings ...)
  2026-01-11  8:09 ` [ruby-core:124473] " tagomoris (Satoshi Tagomori) via ruby-core
@ 2026-02-15  8:13 ` tagomoris (Satoshi Tagomori) via ruby-core
  3 siblings, 0 replies; 5+ messages in thread
From: tagomoris (Satoshi Tagomori) via ruby-core @ 2026-02-15  8:13 UTC (permalink / raw)
  To: ruby-core; +Cc: tagomoris (Satoshi Tagomori)

Issue #21830 has been updated by tagomoris (Satoshi Tagomori).


I'll work on #21881 to solve this problem.

----------------------------------------
Bug #21830: Ruby::Box and Kernel#require
https://bugs.ruby-lang.org/issues/21830#change-116447

* Author: fxn (Xavier Noria)
* Status: Open
* 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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-02-15  8:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-09  9:48 [ruby-core:124461] [Ruby Bug#21830] Ruby::Box and Kernel#require fxn (Xavier Noria) via ruby-core
2026-01-09  9:56 ` [ruby-core:124462] " fxn (Xavier Noria) via ruby-core
2026-01-09 14:07 ` [ruby-core:124463] " fxn (Xavier Noria) via ruby-core
2026-01-11  8:09 ` [ruby-core:124473] " tagomoris (Satoshi Tagomori) via ruby-core
2026-02-15  8:13 ` [ruby-core:124827] " tagomoris (Satoshi Tagomori) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).