Actions
Bug #21761
openNameError: uninitialized constant only when RUBY_BOX=1
Bug #21761:
NameError: uninitialized constant only when RUBY_BOX=1
Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 4.0.0dev (2025-12-03T07:14:56Z master 8c3909935e) +PRISM [x86_64-linux]
Description
This issue is originally found when I tested Ruby::Box against Rails main branch, I think I have created a repro.
Steps to reproduce¶
- Install Ruby master branch
- Follow these steps below.
git clone https://github.com/yahonda/repro-ruby-box-uninitialized-constant
cd repro-ruby-box-uninitialized-constant
RUBY_BOX=1 rake
Expected behavior¶
It should load the configuration as follows.
$ RUBY_BOX=0 rake
Constants defined:
ROOT = /tmp/test
FIXTURES_ROOT = /tmp/test/fixtures
Running test from Rakefile...
--- Loading config.yml with ERB ---
YAML content before ERB processing:
default:
path: <%= FIXTURES_ROOT %>/data
name: test_fixture
Processing ERB...
YAML content after ERB processing:
default:
path: /tmp/test/fixtures/data
name: test_fixture
Parsed config:
{"default" => {"path" => "/tmp/test/fixtures/data", "name" => "test_fixture"}}
SUCCESS: Config loaded successfully
$
Actual behavior¶
It raises the NameError: uninitialized constant FIXTURES_ROOT.
$ RUBY_BOX=1 rake
/home/yahonda/.local/share/mise/installs/ruby/trunk/bin/ruby: warning: Ruby::Box is experimental, and the behavior may change in the future!
See doc/language/box.md for known issues, etc.
Constants defined:
ROOT = /tmp/test
FIXTURES_ROOT = /tmp/test/fixtures
Running test from Rakefile...
--- Loading config.yml with ERB ---
YAML content before ERB processing:
default:
path: <%= FIXTURES_ROOT %>/data
name: test_fixture
Processing ERB...
ERROR: NameError: uninitialized constant FIXTURES_ROOT
(erb):2:in '<main>'
/home/yahonda/.local/share/mise/installs/ruby/trunk/lib/ruby/4.0.0+0/erb.rb:1012:in 'Kernel#eval'
/home/yahonda/.local/share/mise/installs/ruby/trunk/lib/ruby/4.0.0+0/erb.rb:1012:in 'ERB#result'
/home/yahonda/src/github.com/yahonda/repro-ruby-box-uninitialized-constant/test_box.rb:19:in '<top (required)>'
/home/yahonda/src/github.com/yahonda/repro-ruby-box-uninitialized-constant/Rakefile:8:in 'Kernel#require_relative'
$
Updated by yahonda (Yasuo Honda) 22 minutes ago
Here are original issue found.
Steps to reproduce¶
git clone https://github.com/rails/rails
cd rails/activerecord
rm ../Gemfile.lock
bundle install
RUBY_BOX=1 bundle exec rake test
Actual behavior¶
$ RUBY_BOX=1 bundle exec rake test
/home/yahonda/.local/share/mise/installs/ruby/trunk/bin/ruby: warning: Ruby::Box is experimental, and the behavior may change in the future!
See doc/language/box.md for known issues, etc.
Source locally installed gems is ignoring #<Bundler::StubSpecification name=prism version=1.6.0 platform=ruby> because it is missing extensions
Source locally installed gems is ignoring #<Bundler::StubSpecification name=json version=2.16.0 platform=ruby> because it is missing extensions
Source locally installed gems is ignoring #<Bundler::StubSpecification name=erb version=6.0.0 platform=ruby> because it is missing extensions
Source locally installed gems is ignoring #<Bundler::StubSpecification name=date version=3.5.0 platform=ruby> because it is missing extensions
rake aborted!
NameError: uninitialized constant FIXTURES_ROOT (NameError)
/home/yahonda/src/github.com/rails/rails/activerecord/test/config.yml:85:in '<main>'
/home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/configuration_file.rb:57:in 'ActiveSupport::ConfigurationFile#render'
/home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/configuration_file.rb:22:in 'ActiveSupport::ConfigurationFile#parse'
/home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/configuration_file.rb:18:in 'ActiveSupport::ConfigurationFile.parse'
/home/yahonda/src/github.com/rails/rails/activerecord/test/support/config.rb:23:in 'ARTest.read_config'
/home/yahonda/src/github.com/rails/rails/activerecord/test/support/config.rb:10:in 'ARTest.config'
/home/yahonda/src/github.com/rails/rails/activerecord/Rakefile:233:in 'block (2 levels) in <top (required)>'
/home/yahonda/src/github.com/rails/rails/activerecord/Rakefile:232:in 'block in <top (required)>'
/home/yahonda/src/github.com/rails/rails/activerecord/Rakefile:231:in '<top (required)>'
/home/yahonda/.local/share/mise/installs/ruby/trunk/bin/bundle:25:in '<main>'
(See full trace by running task with --trace)
$
Updated by yahonda (Yasuo Honda) 20 minutes ago
It does not reproduce without Rake.
$ RUBY_BOX=1 ruby test_box.rb
ruby: warning: Ruby::Box is experimental, and the behavior may change in the future!
See doc/language/box.md for known issues, etc.
Constants defined:
ROOT = /tmp/test
FIXTURES_ROOT = /tmp/test/fixtures
--- Loading config.yml with ERB ---
YAML content before ERB processing:
default:
path: <%= FIXTURES_ROOT %>/data
name: test_fixture
Processing ERB...
YAML content after ERB processing:
default:
path: /tmp/test/fixtures/data
name: test_fixture
Parsed config:
{"default" => {"path" => "/tmp/test/fixtures/data", "name" => "test_fixture"}}
SUCCESS: Config loaded successfully
$
Actions