Project

General

Profile

Actions

Bug #21761

open

NameError: uninitialized constant only when RUBY_BOX=1

Bug #21761: NameError: uninitialized constant only when RUBY_BOX=1

Added by yahonda (Yasuo Honda) 23 minutes ago. Updated 20 minutes ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 4.0.0dev (2025-12-03T07:14:56Z master 8c3909935e) +PRISM [x86_64-linux]
[ruby-core:124000]

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

  1. Install Ruby master branch
  2. 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'
$
Actions

Also available in: PDF Atom