Skip to content

Order-dependent Zeitwerk failures #8863

@headius

Description

@headius

After working through Zeitwerk compatibility in #8852 for #6781, I boiled things down to a handful of seemingly order-dependent failures (and one known issue relating to path canonicalization).

At least four failures I have seen in test_explicit_namespace.rb seem to be order dependent, and the few I tested pass in isolation. The failures look like this, with some variations:

Error:
TestExplicitNamespace#test_explicit_namespaces_are_loaded_correctly__directory_first__Object_:
NameError: uninitialized constant TestExplicitNamespace::Hotel
    org/jruby/RubyModule.java:4864:in 'const_missing'
    test/lib/zeitwerk/test_explicit_namespace.rb:14:in 'block in TestExplicitNamespace'
...
Error:
TestExplicitNamespace#test_explicit_namespaces_defined_with_an_explicit_constant_assignment_are_loaded_correctly:
NameError: uninitialized constant TestExplicitNamespace::Hotel
    org/jruby/RubyModule.java:4864:in 'const_missing'
    test/lib/zeitwerk/test_explicit_namespace.rb:62:in 'block in TestExplicitNamespace'
...
Error:
TestNestedRootDirectories#test_nested_root_directories_are_ignored_even_if_there_is_a_matching_file:
NameError: uninitialized constant TestNestedRootDirectories::Hotel
    org/jruby/RubyModule.java:4864:in 'const_missing'
    test/lib/zeitwerk/test_nested_root_directories.rb:21:in 'block in TestNestedRootDirectories'
...
Error:
TestRequireInteraction#test_require_works_well_with_explicit_namespaces:
NameError: uninitialized constant Hotel
    org/jruby/RubyModule.java:4866:in 'const_missing'
    test/tmp/hotel/pricing.rb:1:in '<main>'
    org/jruby/RubyKernel.java:1183:in 'require'
    /Users/headius/work/jruby/lib/ruby/stdlib/bundled_gems.rb:81:in 'block in replace_require'
    lib/zeitwerk/core_ext/kernel.rb:34:in 'require'
    test/lib/zeitwerk/test_require_interaction.rb:8:in 'assert_required'
    test/lib/zeitwerk/test_require_interaction.rb:122:in 'block in TestRequireInteraction'
...
Failure:
TestExplicitNamespace#test_if_the_expected_constant_does_not_define_a_class_or_module_object__we_raise_a_controlled_error [/Users/headius/work/zeitwerk/test/lib/zeitwerk/test_explicit_namespace.rb:178]
Minitest::Assertion: [Zeitwerk::Error] exception expected, not
Class: <NameError>
Message: <"uninitialized constant TestExplicitNamespace::Hotel">
---Backtrace---
org/jruby/RubyModule.java:4864:in 'const_missing'
/Users/headius/work/zeitwerk/test/lib/zeitwerk/test_explicit_namespace.rb:178:in 'block in TestExplicitNamespace'
---------------
...
Error:
TestExplicitNamespace#test_explicit_namespaces_are_loaded_correctly__directory_first__Namespace_:
NameError: uninitialized constant TestExplicitNamespace::Namespace::Hotel
    org/jruby/RubyModule.java:4864:in 'const_missing'
    test/lib/zeitwerk/test_explicit_namespace.rb:26:in 'block in TestExplicitNamespace'
...
Error:
TestExplicitNamespace#test_explicit_namespaces_are_loaded_correctly_even_if__name_is_overridden:
NameError: uninitialized constant TestExplicitNamespace::Hotel
    org/jruby/RubyModule.java:4864:in 'const_missing'
    test/lib/zeitwerk/test_explicit_namespace.rb:80:in 'block in TestExplicitNamespace'

Pinging @fxn for some tips on what to look for!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions