* [ruby-core:121988] [Ruby Bug#21324] Namespace loads RubyGems in root Namespace but it should not
@ 2025-05-10 12:36 Eregon (Benoit Daloze) via ruby-core
2025-05-11 1:13 ` [ruby-core:121996] " mame (Yusuke Endoh) via ruby-core
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2025-05-10 12:36 UTC (permalink / raw)
To: ruby-core; +Cc: Eregon (Benoit Daloze)
Issue #21324 has been reported by Eregon (Benoit Daloze).
----------------------------------------
Bug #21324: Namespace loads RubyGems in root Namespace but it should not
https://bugs.ruby-lang.org/issues/21324
* Author: Eregon (Benoit Daloze)
* Status: Open
* ruby -v: ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
RubyGems has tons of mutable state, isn't core library and isn't "builtin classes" either, so it should not be in root Namespace, as it is currently:
```
$ RUBY_NAMESPACE=1 ruby -ve 'ns = Namespace.new; p ns::Gem.equal?(Gem)'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
true
```
A concrete example of what breaks most likely due to this:
```
$ gem i delegate:0.3.1
$ RUBY_NAMESPACE=1 ruby -ve 'require "delegate"; p Delegator::VERSION; ns = Namespace.new; File.write "ns.rb", "gem %{delegate}, %{0.3.1}; require :delegate.to_s; p Delegator::VERSION"; ns.require "./ns"'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
"0.4.0"
/home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/specification.rb:2232:in 'Gem::Specification#check_version_conflict': can't activate delegate-0.3.1, already activated delegate-0.4.0 (Gem::LoadError)
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/specification.rb:1383:in 'Gem::Specification#activate'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'block in Kernel#gem'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'Thread::Mutex#synchronize'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'Kernel#gem'
from /home/eregon/ns.rb:1:in '<top (required)>'
from -e:1:in 'Namespace#require'
from -e:1:in '<main>'
```
i.e. `ns` sees delegate-0.4.0 was loaded in main namespace but it shouldn't.
Previously mentioned in https://bugs.ruby-lang.org/issues/21311#note-36
--
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] 9+ messages in thread
* [ruby-core:121996] [Ruby Bug#21324] Namespace loads RubyGems in root Namespace but it should not
2025-05-10 12:36 [ruby-core:121988] [Ruby Bug#21324] Namespace loads RubyGems in root Namespace but it should not Eregon (Benoit Daloze) via ruby-core
@ 2025-05-11 1:13 ` mame (Yusuke Endoh) via ruby-core
2025-05-11 3:44 ` [ruby-core:121998] " mame (Yusuke Endoh) via ruby-core
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: mame (Yusuke Endoh) via ruby-core @ 2025-05-11 1:13 UTC (permalink / raw)
To: ruby-core; +Cc: mame (Yusuke Endoh)
Issue #21324 has been updated by mame (Yusuke Endoh).
Assignee set to prism
----------------------------------------
Bug #21324: Namespace loads RubyGems in root Namespace but it should not
https://bugs.ruby-lang.org/issues/21324#change-113114
* Author: Eregon (Benoit Daloze)
* Status: Open
* Assignee: prism
* ruby -v: ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
RubyGems has tons of mutable state, isn't core library and isn't "builtin classes" either, so it should not be in root Namespace, but it is currently:
```
$ RUBY_NAMESPACE=1 ruby -ve 'ns = Namespace.new; p ns::Gem.equal?(Gem)'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
true
```
A concrete example of what breaks most likely due to this:
```
$ gem i delegate:0.3.1
$ RUBY_NAMESPACE=1 ruby -ve 'require "delegate"; p Delegator::VERSION; ns = Namespace.new; File.write "ns.rb", "gem %{delegate}, %{0.3.1}; require :delegate.to_s; p Delegator::VERSION"; ns.require "./ns"'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
"0.4.0"
/home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/specification.rb:2232:in 'Gem::Specification#check_version_conflict': can't activate delegate-0.3.1, already activated delegate-0.4.0 (Gem::LoadError)
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/specification.rb:1383:in 'Gem::Specification#activate'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'block in Kernel#gem'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'Thread::Mutex#synchronize'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'Kernel#gem'
from /home/eregon/ns.rb:1:in '<top (required)>'
from -e:1:in 'Namespace#require'
from -e:1:in '<main>'
```
i.e. `ns` sees delegate-0.4.0 was loaded in main namespace but it shouldn't.
Previously mentioned in https://bugs.ruby-lang.org/issues/21311#note-36
--
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] 9+ messages in thread
* [ruby-core:121998] [Ruby Bug#21324] Namespace loads RubyGems in root Namespace but it should not
2025-05-10 12:36 [ruby-core:121988] [Ruby Bug#21324] Namespace loads RubyGems in root Namespace but it should not Eregon (Benoit Daloze) via ruby-core
2025-05-11 1:13 ` [ruby-core:121996] " mame (Yusuke Endoh) via ruby-core
@ 2025-05-11 3:44 ` mame (Yusuke Endoh) via ruby-core
2025-05-13 6:47 ` [ruby-core:122039] " jas (Jasveen Sandral) via ruby-core
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: mame (Yusuke Endoh) via ruby-core @ 2025-05-11 3:44 UTC (permalink / raw)
To: ruby-core; +Cc: mame (Yusuke Endoh)
Issue #21324 has been updated by mame (Yusuke Endoh).
Assignee deleted (prism)
----------------------------------------
Bug #21324: Namespace loads RubyGems in root Namespace but it should not
https://bugs.ruby-lang.org/issues/21324#change-113116
* Author: Eregon (Benoit Daloze)
* Status: Open
* ruby -v: ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
RubyGems has tons of mutable state, isn't core library and isn't "builtin classes" either, so it should not be in root Namespace, but it is currently:
```
$ RUBY_NAMESPACE=1 ruby -ve 'ns = Namespace.new; p ns::Gem.equal?(Gem)'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
true
```
A concrete example of what breaks most likely due to this:
```
$ gem i delegate:0.3.1
$ RUBY_NAMESPACE=1 ruby -ve 'require "delegate"; p Delegator::VERSION; ns = Namespace.new; File.write "ns.rb", "gem %{delegate}, %{0.3.1}; require :delegate.to_s; p Delegator::VERSION"; ns.require "./ns"'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
"0.4.0"
/home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/specification.rb:2232:in 'Gem::Specification#check_version_conflict': can't activate delegate-0.3.1, already activated delegate-0.4.0 (Gem::LoadError)
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/specification.rb:1383:in 'Gem::Specification#activate'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'block in Kernel#gem'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'Thread::Mutex#synchronize'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'Kernel#gem'
from /home/eregon/ns.rb:1:in '<top (required)>'
from -e:1:in 'Namespace#require'
from -e:1:in '<main>'
```
i.e. `ns` sees delegate-0.4.0 was loaded in main namespace but it shouldn't.
Previously mentioned in https://bugs.ruby-lang.org/issues/21311#note-36
--
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] 9+ messages in thread
* [ruby-core:122039] [Ruby Bug#21324] Namespace loads RubyGems in root Namespace but it should not
2025-05-10 12:36 [ruby-core:121988] [Ruby Bug#21324] Namespace loads RubyGems in root Namespace but it should not Eregon (Benoit Daloze) via ruby-core
2025-05-11 1:13 ` [ruby-core:121996] " mame (Yusuke Endoh) via ruby-core
2025-05-11 3:44 ` [ruby-core:121998] " mame (Yusuke Endoh) via ruby-core
@ 2025-05-13 6:47 ` jas (Jasveen Sandral) via ruby-core
2025-05-13 11:40 ` [ruby-core:122047] " Eregon (Benoit Daloze) via ruby-core
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jas (Jasveen Sandral) via ruby-core @ 2025-05-13 6:47 UTC (permalink / raw)
To: ruby-core; +Cc: jas (Jasveen Sandral)
Issue #21324 has been updated by jas (Jasveen Sandral).
I've identified the issue and prepared a fix.
The problem is that RubyGems is being loaded into the root namespace during Ruby's boot process, and then all user namespaces inherit this same Gem constant through the Copy-on-Write mechanism. This causes all namespaces to share the same RubyGems environment and state, leading to version conflicts.
The fix involves:
1. In `rb_initialize_main_namespace()`:
- Detecting if the Gem constant exists in Object
- Removing it explicitly with rb_const_remove()
- Loading a fresh RubyGems environment
2. In `namespace_initialize()` (for Namespace.new):
- Getting the namespace's own Object constant
- Checking and removing any inherited Gem constant
- Loading a clean RubyGems environment
This ensures each namespace (main and optional) gets its own isolated RubyGems state, preventing version conflicts when loading gems across namespaces.
I've created a PR with these changes: https://github.com/ruby/ruby/pull/13313
----------------------------------------
Bug #21324: Namespace loads RubyGems in root Namespace but it should not
https://bugs.ruby-lang.org/issues/21324#change-113188
* Author: Eregon (Benoit Daloze)
* Status: Open
* ruby -v: ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
RubyGems has tons of mutable state, isn't core library and isn't "builtin classes" either, so it should not be in root Namespace, but it is currently:
```
$ RUBY_NAMESPACE=1 ruby -ve 'ns = Namespace.new; p ns::Gem.equal?(Gem)'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
true
```
A concrete example of what breaks most likely due to this:
```
$ gem i delegate:0.3.1
$ RUBY_NAMESPACE=1 ruby -ve 'require "delegate"; p Delegator::VERSION; ns = Namespace.new; File.write "ns.rb", "gem %{delegate}, %{0.3.1}; require :delegate.to_s; p Delegator::VERSION"; ns.require "./ns"'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
"0.4.0"
/home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/specification.rb:2232:in 'Gem::Specification#check_version_conflict': can't activate delegate-0.3.1, already activated delegate-0.4.0 (Gem::LoadError)
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/specification.rb:1383:in 'Gem::Specification#activate'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'block in Kernel#gem'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'Thread::Mutex#synchronize'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'Kernel#gem'
from /home/eregon/ns.rb:1:in '<top (required)>'
from -e:1:in 'Namespace#require'
from -e:1:in '<main>'
```
i.e. `ns` sees delegate-0.4.0 was loaded in main namespace but it shouldn't.
Previously mentioned in https://bugs.ruby-lang.org/issues/21311#note-36
--
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] 9+ messages in thread
* [ruby-core:122047] [Ruby Bug#21324] Namespace loads RubyGems in root Namespace but it should not
2025-05-10 12:36 [ruby-core:121988] [Ruby Bug#21324] Namespace loads RubyGems in root Namespace but it should not Eregon (Benoit Daloze) via ruby-core
` (2 preceding siblings ...)
2025-05-13 6:47 ` [ruby-core:122039] " jas (Jasveen Sandral) via ruby-core
@ 2025-05-13 11:40 ` Eregon (Benoit Daloze) via ruby-core
2025-12-09 12:48 ` [ruby-core:124092] " tagomoris (Satoshi Tagomori) via ruby-core
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2025-05-13 11:40 UTC (permalink / raw)
To: ruby-core; +Cc: Eregon (Benoit Daloze)
Issue #21324 has been updated by Eregon (Benoit Daloze).
Loading RubyGems creates more constants than just `Gem`:
```
$ ruby -v --disable-gems -e 'a=Object.constants; require "rubygems"; b=Object.constants; p b-a'
ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux]
[:Monitor, :MonitorMixin, :Gem, :CROSS_COMPILING, :RbConfig, :RUBYGEMS_ACTIVATION_MONITOR]
```
It seems very messy to try to remove that from the root namespace.
The clean solution seems obvious: `gem_prelude.rb` shouldn't be loaded in the root namespace, but only in user namespaces.
----------------------------------------
Bug #21324: Namespace loads RubyGems in root Namespace but it should not
https://bugs.ruby-lang.org/issues/21324#change-113197
* Author: Eregon (Benoit Daloze)
* Status: Open
* ruby -v: ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
RubyGems has tons of mutable state, isn't core library and isn't "builtin classes" either, so it should not be in root Namespace, but it is currently:
```
$ RUBY_NAMESPACE=1 ruby -ve 'ns = Namespace.new; p ns::Gem.equal?(Gem)'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
true
```
A concrete example of what breaks most likely due to this:
```
$ gem i delegate:0.3.1
$ RUBY_NAMESPACE=1 ruby -ve 'require "delegate"; p Delegator::VERSION; ns = Namespace.new; File.write "ns.rb", "gem %{delegate}, %{0.3.1}; require :delegate.to_s; p Delegator::VERSION"; ns.require "./ns"'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
"0.4.0"
/home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/specification.rb:2232:in 'Gem::Specification#check_version_conflict': can't activate delegate-0.3.1, already activated delegate-0.4.0 (Gem::LoadError)
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/specification.rb:1383:in 'Gem::Specification#activate'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'block in Kernel#gem'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'Thread::Mutex#synchronize'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'Kernel#gem'
from /home/eregon/ns.rb:1:in '<top (required)>'
from -e:1:in 'Namespace#require'
from -e:1:in '<main>'
```
i.e. `ns` sees delegate-0.4.0 was loaded in main namespace but it shouldn't.
Previously mentioned in https://bugs.ruby-lang.org/issues/21311#note-36
--
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] 9+ messages in thread
* [ruby-core:124092] [Ruby Bug#21324] Namespace loads RubyGems in root Namespace but it should not
2025-05-10 12:36 [ruby-core:121988] [Ruby Bug#21324] Namespace loads RubyGems in root Namespace but it should not Eregon (Benoit Daloze) via ruby-core
` (3 preceding siblings ...)
2025-05-13 11:40 ` [ruby-core:122047] " Eregon (Benoit Daloze) via ruby-core
@ 2025-12-09 12:48 ` tagomoris (Satoshi Tagomori) via ruby-core
2025-12-18 9:48 ` [ruby-core:124300] " Eregon (Benoit Daloze) via ruby-core
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: tagomoris (Satoshi Tagomori) via ruby-core @ 2025-12-09 12:48 UTC (permalink / raw)
To: ruby-core; +Cc: tagomoris (Satoshi Tagomori)
Issue #21324 has been updated by tagomoris (Satoshi Tagomori).
Assignee set to tagomoris (Satoshi Tagomori)
----------------------------------------
Bug #21324: Namespace loads RubyGems in root Namespace but it should not
https://bugs.ruby-lang.org/issues/21324#change-115536
* Author: Eregon (Benoit Daloze)
* Status: Open
* Assignee: tagomoris (Satoshi Tagomori)
* ruby -v: ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
RubyGems has tons of mutable state, isn't core library and isn't "builtin classes" either, so it should not be in root Namespace, but it is currently:
```
$ RUBY_NAMESPACE=1 ruby -ve 'ns = Namespace.new; p ns::Gem.equal?(Gem)'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
true
```
A concrete example of what breaks most likely due to this:
```
$ gem i delegate:0.3.1
$ RUBY_NAMESPACE=1 ruby -ve 'require "delegate"; p Delegator::VERSION; ns = Namespace.new; File.write "ns.rb", "gem %{delegate}, %{0.3.1}; require :delegate.to_s; p Delegator::VERSION"; ns.require "./ns"'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
"0.4.0"
/home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/specification.rb:2232:in 'Gem::Specification#check_version_conflict': can't activate delegate-0.3.1, already activated delegate-0.4.0 (Gem::LoadError)
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/specification.rb:1383:in 'Gem::Specification#activate'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'block in Kernel#gem'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'Thread::Mutex#synchronize'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'Kernel#gem'
from /home/eregon/ns.rb:1:in '<top (required)>'
from -e:1:in 'Namespace#require'
from -e:1:in '<main>'
```
i.e. `ns` sees delegate-0.4.0 was loaded in main namespace but it shouldn't.
Previously mentioned in https://bugs.ruby-lang.org/issues/21311#note-36
--
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] 9+ messages in thread
* [ruby-core:124300] [Ruby Bug#21324] Namespace loads RubyGems in root Namespace but it should not
2025-05-10 12:36 [ruby-core:121988] [Ruby Bug#21324] Namespace loads RubyGems in root Namespace but it should not Eregon (Benoit Daloze) via ruby-core
` (4 preceding siblings ...)
2025-12-09 12:48 ` [ruby-core:124092] " tagomoris (Satoshi Tagomori) via ruby-core
@ 2025-12-18 9:48 ` Eregon (Benoit Daloze) via ruby-core
2026-02-07 6:23 ` [ruby-core:124707] " jneen (Jeanine Adkisson) via ruby-core
2026-02-15 8:13 ` [ruby-core:124826] " tagomoris (Satoshi Tagomori) via ruby-core
7 siblings, 0 replies; 9+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2025-12-18 9:48 UTC (permalink / raw)
To: ruby-core; +Cc: Eregon (Benoit Daloze)
Issue #21324 has been updated by Eregon (Benoit Daloze).
I have tried for curiosity with `ruby 4.0.0preview3` and it is still unfixed:
```
$ RUBY_BOX=1 ruby -ve 'ns = Ruby::Box.new; p ns::Gem.equal?(Gem)'
ruby 4.0.0preview3 (2025-12-18 master cfa3e7cf75) +PRISM [x86_64-linux]
ruby: warning: Ruby::Box is experimental, and the behavior may change in the future!
See doc/language/box.md for known issues, etc.
true
```
Also the `gem` method doesn't work with `RUBY_BOX=1`:
```
$ gem i json:2.17.1
$ ruby -e 'gem %{json}, %{2.17.1}; require %{json}; p JSON::VERSION'
"2.17.1"
$ RUBY_BOX=1 ruby -e 'gem %{json}, %{2.17.1}; require %{json}; p JSON::VERSION'
ruby: warning: Ruby::Box is experimental, and the behavior may change in the future!
See doc/language/box.md for known issues, etc.
"2.18.0"
$ RUBY_BOX=1 ruby -e 'b1 = Ruby::Box.new; json1 = b1.eval "gem %{json}, %{2.17.1}; require %{json}; JSON"; p json1::VERSION'
ruby: warning: Ruby::Box is experimental, and the behavior may change in the future!
See doc/language/box.md for known issues, etc.
"2.18.0"
```
----------------------------------------
Bug #21324: Namespace loads RubyGems in root Namespace but it should not
https://bugs.ruby-lang.org/issues/21324#change-115798
* Author: Eregon (Benoit Daloze)
* Status: Open
* Assignee: tagomoris (Satoshi Tagomori)
* ruby -v: ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
RubyGems has tons of mutable state, isn't core library and isn't "builtin classes" either, so it should not be in root Namespace, but it is currently:
```
$ RUBY_NAMESPACE=1 ruby -ve 'ns = Namespace.new; p ns::Gem.equal?(Gem)'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
true
```
A concrete example of what breaks most likely due to this:
```
$ gem i delegate:0.3.1
$ RUBY_NAMESPACE=1 ruby -ve 'require "delegate"; p Delegator::VERSION; ns = Namespace.new; File.write "ns.rb", "gem %{delegate}, %{0.3.1}; require :delegate.to_s; p Delegator::VERSION"; ns.require "./ns"'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
"0.4.0"
/home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/specification.rb:2232:in 'Gem::Specification#check_version_conflict': can't activate delegate-0.3.1, already activated delegate-0.4.0 (Gem::LoadError)
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/specification.rb:1383:in 'Gem::Specification#activate'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'block in Kernel#gem'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'Thread::Mutex#synchronize'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'Kernel#gem'
from /home/eregon/ns.rb:1:in '<top (required)>'
from -e:1:in 'Namespace#require'
from -e:1:in '<main>'
```
i.e. `ns` sees delegate-0.4.0 was loaded in main namespace but it shouldn't.
Previously mentioned in https://bugs.ruby-lang.org/issues/21311#note-36
--
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] 9+ messages in thread
* [ruby-core:124707] [Ruby Bug#21324] Namespace loads RubyGems in root Namespace but it should not
2025-05-10 12:36 [ruby-core:121988] [Ruby Bug#21324] Namespace loads RubyGems in root Namespace but it should not Eregon (Benoit Daloze) via ruby-core
` (5 preceding siblings ...)
2025-12-18 9:48 ` [ruby-core:124300] " Eregon (Benoit Daloze) via ruby-core
@ 2026-02-07 6:23 ` jneen (Jeanine Adkisson) via ruby-core
2026-02-15 8:13 ` [ruby-core:124826] " tagomoris (Satoshi Tagomori) via ruby-core
7 siblings, 0 replies; 9+ messages in thread
From: jneen (Jeanine Adkisson) via ruby-core @ 2026-02-07 6:23 UTC (permalink / raw)
To: ruby-core; +Cc: jneen (Jeanine Adkisson)
Issue #21324 has been updated by jneen (Jeanine Adkisson).
As mentioned here: https://bugs.ruby-lang.org/issues/21323#note-6
After some experimentation it looks to me as if the result of this bug is that all gem executables and their dependencies are loaded in the root box, due to a plain `load(...)` call in rubygems.rb.
----------------------------------------
Bug #21324: Namespace loads RubyGems in root Namespace but it should not
https://bugs.ruby-lang.org/issues/21324#change-116302
* Author: Eregon (Benoit Daloze)
* Status: Open
* Assignee: tagomoris (Satoshi Tagomori)
* ruby -v: ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
RubyGems has tons of mutable state, isn't core library and isn't "builtin classes" either, so it should not be in root Namespace, but it is currently:
```
$ RUBY_NAMESPACE=1 ruby -ve 'ns = Namespace.new; p ns::Gem.equal?(Gem)'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
true
```
A concrete example of what breaks most likely due to this:
```
$ gem i delegate:0.3.1
$ RUBY_NAMESPACE=1 ruby -ve 'require "delegate"; p Delegator::VERSION; ns = Namespace.new; File.write "ns.rb", "gem %{delegate}, %{0.3.1}; require :delegate.to_s; p Delegator::VERSION"; ns.require "./ns"'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
"0.4.0"
/home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/specification.rb:2232:in 'Gem::Specification#check_version_conflict': can't activate delegate-0.3.1, already activated delegate-0.4.0 (Gem::LoadError)
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/specification.rb:1383:in 'Gem::Specification#activate'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'block in Kernel#gem'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'Thread::Mutex#synchronize'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'Kernel#gem'
from /home/eregon/ns.rb:1:in '<top (required)>'
from -e:1:in 'Namespace#require'
from -e:1:in '<main>'
```
i.e. `ns` sees delegate-0.4.0 was loaded in main namespace but it shouldn't.
Previously mentioned in https://bugs.ruby-lang.org/issues/21311#note-36
--
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] 9+ messages in thread
* [ruby-core:124826] [Ruby Bug#21324] Namespace loads RubyGems in root Namespace but it should not
2025-05-10 12:36 [ruby-core:121988] [Ruby Bug#21324] Namespace loads RubyGems in root Namespace but it should not Eregon (Benoit Daloze) via ruby-core
` (6 preceding siblings ...)
2026-02-07 6:23 ` [ruby-core:124707] " jneen (Jeanine Adkisson) via ruby-core
@ 2026-02-15 8:13 ` tagomoris (Satoshi Tagomori) via ruby-core
7 siblings, 0 replies; 9+ 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 #21324 has been updated by tagomoris (Satoshi Tagomori).
I'll work on https://bugs.ruby-lang.org/issues/21881 to solve this problem.
----------------------------------------
Bug #21324: Namespace loads RubyGems in root Namespace but it should not
https://bugs.ruby-lang.org/issues/21324#change-116446
* Author: Eregon (Benoit Daloze)
* Status: Open
* Assignee: tagomoris (Satoshi Tagomori)
* ruby -v: ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
RubyGems has tons of mutable state, isn't core library and isn't "builtin classes" either, so it should not be in root Namespace, but it is currently:
```
$ RUBY_NAMESPACE=1 ruby -ve 'ns = Namespace.new; p ns::Gem.equal?(Gem)'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
true
```
A concrete example of what breaks most likely due to this:
```
$ gem i delegate:0.3.1
$ RUBY_NAMESPACE=1 ruby -ve 'require "delegate"; p Delegator::VERSION; ns = Namespace.new; File.write "ns.rb", "gem %{delegate}, %{0.3.1}; require :delegate.to_s; p Delegator::VERSION"; ns.require "./ns"'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
"0.4.0"
/home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/specification.rb:2232:in 'Gem::Specification#check_version_conflict': can't activate delegate-0.3.1, already activated delegate-0.4.0 (Gem::LoadError)
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/specification.rb:1383:in 'Gem::Specification#activate'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'block in Kernel#gem'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'Thread::Mutex#synchronize'
from /home/eregon/prefix/ruby-master/lib/ruby/3.5.0+0/rubygems/core_ext/kernel_gem.rb:62:in 'Kernel#gem'
from /home/eregon/ns.rb:1:in '<top (required)>'
from -e:1:in 'Namespace#require'
from -e:1:in '<main>'
```
i.e. `ns` sees delegate-0.4.0 was loaded in main namespace but it shouldn't.
Previously mentioned in https://bugs.ruby-lang.org/issues/21311#note-36
--
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] 9+ messages in thread
end of thread, other threads:[~2026-02-15 8:15 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-10 12:36 [ruby-core:121988] [Ruby Bug#21324] Namespace loads RubyGems in root Namespace but it should not Eregon (Benoit Daloze) via ruby-core
2025-05-11 1:13 ` [ruby-core:121996] " mame (Yusuke Endoh) via ruby-core
2025-05-11 3:44 ` [ruby-core:121998] " mame (Yusuke Endoh) via ruby-core
2025-05-13 6:47 ` [ruby-core:122039] " jas (Jasveen Sandral) via ruby-core
2025-05-13 11:40 ` [ruby-core:122047] " Eregon (Benoit Daloze) via ruby-core
2025-12-09 12:48 ` [ruby-core:124092] " tagomoris (Satoshi Tagomori) via ruby-core
2025-12-18 9:48 ` [ruby-core:124300] " Eregon (Benoit Daloze) via ruby-core
2026-02-07 6:23 ` [ruby-core:124707] " jneen (Jeanine Adkisson) via ruby-core
2026-02-15 8:13 ` [ruby-core:124826] " 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).