Having some trouble working out the migration from Classic to Zeitwerk.
After enabling zeitwerk and running rails s
, everything seems to work. Then after saving a .rb file and refreshing, I'm seeing an "uninitialized constant" error when trying to require a file from the top level /lib
.
Something is misconfigured w/ reloading, but I'm scratching my head trying to work out the details. I was under the impression that having a top level /lib
folder is fine and using require
to load files in that directory is compatible with Zeitwerk, but now I'm not so sure... ideas as to what I'm getting wrong?
Note: I'm not currently setting any specific eager_load_paths
or autoload_paths
EDIT: updated with logging output as suggested by @Xavier
Zeitwerk@rails.main: module CustomModule autovivified from directory *********/app/workers/custom_module
Zeitwerk@rails.main: autoload set for CustomModule::Profiler, to be loaded from *********/app/workers/custom_module/profiler.rb
Zeitwerk@rails.main: autoload set for CustomModule::AnotherProfiler, to be loaded from *********/app/workers/custom_module/another_profiler.rb
NameError - uninitialized constant CustomModule::AttributeParser
Did you mean? NameParserConstants:
app/models/user.rb:180:in `first_name'
app/middleware/catch_json_parse_errors.rb:8:in `call'
app/middleware/decompress_requests.rb:22:in `call'