summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorSatoshi Tagomori <s-tagomori@sakura.ad.jp>2025-12-09 23:03:41 +0900
committerSatoshi Tagomori <tagomoris@gmail.com>2025-12-09 23:08:33 +0900
commite8568bbcf20fafcb82d8b537b99762528dfbdc3e (patch)
treefd1ac30354dd3b12a7189d29a7dfc36abe4c0302 /doc
parentcb9510f539e12f7c58bf2e74186c6a48b62fec3c (diff)
[DOC] Update Ruby Box documents (known issues)
Diffstat (limited to 'doc')
-rw-r--r--doc/language/box.md22
1 files changed, 18 insertions, 4 deletions
diff --git a/doc/language/box.md b/doc/language/box.md
index 928c98eb3c..dc4b3201b4 100644
--- a/doc/language/box.md
+++ b/doc/language/box.md
@@ -5,14 +5,14 @@ Ruby Box is designed to provide separated spaces in a Ruby process, to isolate a
## Known issues
* Experimental warning is shown when ruby starts with `RUBY_BOX=1` (specify `-W:no-experimental` option to hide it)
-* `bundle install` may fail
-* `require 'active_support'` may fail
-* A wrong current namespace detection happens sometimes in the root namespace
+* Installing native extensions may fail under `RUBY_BOX=1` because of stack level too deep in extconf.rb
+* `require 'active_support/core_ext'` may fail under `RUBY_BOX=1`
+* Defined methods in a box may not be referred by built-in methods written in Ruby
## TODOs
* Add the loaded namespace on iseq to check if another namespace tries running the iseq (add a field only when VM_CHECK_MODE?)
-* Delete per-box extension files (.so) lazily or process exit (on Windows)
+* Delete per-box extension files (.dll) lazily or process exit (on Windows)
* Assign its own TOPLEVEL_BINDING in boxes
* Fix calling `warn` in boxes to refer `$VERBOSE` and `Warning.warn` in the box
* Make an internal data container class `Ruby::Box::Entry` invisible
@@ -258,6 +258,16 @@ Ruby Box works in file scope. One `.rb` file runs in a single box.
Once a file is loaded in a box `box`, all methods/procs defined/created in the file run in `box`.
+### Utility methods
+
+Several methods are available for trying/testing Ruby Box.
+
+* `Ruby::Box.current` returns the current box
+* `Ruby::Box.enabled?` returns true/false to represent `RUBY_BOX=1` is specified or not
+* `Ruby::Box.root` returns the root box
+* `Ruby::Box.main` returns the main box
+* `Ruby::Box#eval` evaluates a Ruby code (String) in the receiver box, just like calling `#load` with a file
+
## Implementation details
#### ISeq inline method/constant cache
@@ -294,6 +304,10 @@ It is a breaking change.
Users can define methods using `Ruby::Box.root.eval(...)`, but it's clearly not ideal API.
+#### Assigning values to global variables used by builtin methods
+
+Similar to monkey patching methods, global variables assigned in a box is separated from the root box. Methods defined in the root box referring a global variable can't find the re-assigned one.
+
#### Context of `$LOAD_PATH` and `$LOADED_FEATURES`
Global variables `$LOAD_PATH` and `$LOADED_FEATURES` control `require` method behaviors. So those variables are determined by the loading box instead of the current box.