[Bug] resolve module namespaces
xfifix opened this issue · 4 comments
Description
I'm trying to do a ddd style in the packages. so i created the packages product and and created in the directory app application, domain, infrastructure and used the module application, the module domain and the module infrastructure. it can't load the module but when i remove these modules it works.
To Reproduce
create a packages and create in the directory app, the directory application and a ruby class with module Application ..
Version Information
- Packwerk: 3.0.1
- Ruby 3.2.1
I think to resolve this problem we'll need a little more information. Ideally you would create a simple demo repository that lets people reproduce the problem you're seeing. But giving us a full listing of your folder structure (e.g. with tree -l2 app
) would help too.
yes i made a draft : https://github.com/xfifix/poc-ddd-rails
I'd recommend to look into how zeitwerk, Rails' autoloader, resolves constants. Your namespacing doesn't align with your folder structure. One of the problems is that app/*/
folders are root folders for autoloading so zeitwerk (and packwerk) expects that to be the root of the namespace too. The zeitwerk docs will tell you more.
If you're lucky, rake zeitwerk:check
will point you to the problems on your application.
@exterm is correct, this is am autoloading issue with your application code. Please refer to the Rails guides for help. Closing.