Error: We could not extract autoload paths from your Rails app
nvjkmr opened this issue · 1 comments
nvjkmr commented
Description
When I run bin/packwerk validate
, it errors out.
📦 Packwerk is running validation...
/bundle/path/ruby/3.0.0/gems/packwerk-3.1.0/lib/packwerk/rails_load_paths.rb:67:in `assert_load_paths_present': We could not extract autoload paths from your Rails app. This is likely a configuration error. (RuntimeError)
Packwerk will not work correctly without any autoload paths.
To Reproduce
N/A
Expected Behaviour
Run validate and print issues
Version Information
- Packwerk: v3.1.0
- Ruby v3.0.2p107
Additional Context
Contents of config/application.rb
:
config.eager_load = false
config.eager_load_paths += %W(#{config.root}/api)
config.eager_load_paths += Dir["#{config.root}/api/**/*"]
config.paths.add "#{config.root}/api", glob: "**/*.rb"
config.eager_load_paths += Dir["#{config.root}/app/jobs/*"]
config.eager_load_paths += %W(#{config.root}/lib)
config.eager_load_paths += Dir["#{config.root}/lib/**/"]
config.eager_load_paths += %W(#{config.root}/domains)
config.eager_load_paths += %W(#{config.root}/domains/**/)
gmcgibbon commented
By the looks of it, you are adding paths to eager load paths only (and not your autoload paths). Packwerk (and Zeitwerk) use autoload paths, so you'll want to add these to autoload paths as well for things to work. You can verify if paths are autoload compliant by using bin/rails zeitwerk:check
. If you need additional help, please provide an application with the problem you are describing.
This isn't a bug, so I'm going to close this issue. Thanks!