[#122258] [Ruby Misc#21367] Remove link to ruby-doc.org from www.ruby-lang.org/en/documentation/ — "p8 (Petrik de Heus) via ruby-core" <ruby-core@...>
Issue #21367 has been reported by p8 (Petrik de Heus).
11 messages
2025/05/23
[ruby-core:122112] [Ruby Bug#21339] Namespace: `RubyVM::InstructionSequence.load_iseq` isn't called for the root namespace
From:
"mame (Yusuke Endoh) via ruby-core" <ruby-core@...>
Date:
2025-05-15 01:58:05 UTC
List:
ruby-core #122112
Issue #21339 has been updated by mame (Yusuke Endoh).
It works as expected with `--disable=gems`.
```
$ RUBY_NAMESPACE=1 ./local/bin/ruby --disable=gems test.rb
./local/bin/ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for known issues, etc.
main:
[:load_iseq, "/tmp/test-file.rb"]
namespace:
[:load_iseq, "/tmp/test-file.rb"]
```
But it does not by default.
```
$ RUBY_NAMESPACE=1 ./local/bin/ruby test.rb
./local/bin/ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for known issues, etc.
main:
namespace:
[:load_iseq, "/tmp/test-file.rb"]
```
The reason seems to be that rubygems's require monkey patch does not work in sub namespace.
```ruby
# with RUBY_NAMESPACE=1
puts "main:"
require "csv" #=> OK
if ENV["RUBY_NAMESPACE"]
puts "namespace:"
ns = Namespace.new
# csv is a bundled gem, so rubygems is needed to require it
ns.require("csv") #=> cannot load such file -- csv (LoadError)
end
```
Thus, there are two problems
* load_iseq does not fire via RubyGems require monkey patch.
* RubyGems require monkey patch does not work in sub namespaces.
----------------------------------------
Bug #21339: Namespace: `RubyVM::InstructionSequence.load_iseq` isn't called for the root namespace
https://bugs.ruby-lang.org/issues/21339#change-113265
* Author: byroot (Jean Boussier)
* Status: Assigned
* Assignee: tagomoris (Satoshi Tagomori)
* ruby -v: ruby 3.5.0dev (2025-05-14T12:41:46Z master b5575a80bc) +PRISM [arm64-darwin24]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
```ruby
File.write("/tmp/compile-cache.rb", <<~'RUBY')
class << RubyVM::InstructionSequence
def load_iseq(path)
p [:load_iseq, path]
RubyVM::InstructionSequence.compile_file(path)
end
end
RUBY
File.write("/tmp/test-file.rb", "")
puts "main:"
require "/tmp/compile-cache.rb"
require "/tmp/test-file.rb"
if ENV["RUBY_NAMESPACE"]
puts "namespace:"
ns = Namespace.new
ns.require("/tmp/compile-cache.rb")
ns.require("/tmp/test-file.rb")
end
```
Expected behavior:
I would expect `load_iseq` to be invoked both in the root namespace and the user namespace when `RUBY_NAMESPACE=1`.
Actual behavior:
Somehow it's only invoked in the user namespace:
```bash
main:
[:compile_cache_setup]
[:load_iseq, "/tmp/test-file.rb"]
```
```bash
main:
[:compile_cache_setup]
namespace:
[:compile_cache_setup]
[:load_iseq, "/tmp/test-file.rb"]
```
But I don't understand why.
--
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/