Shopify / packwerk

Good things come in small packages.
MIT License
1.54k stars 111 forks source link

Error: We could not extract autoload paths from your Rails app #381

Closed nvjkmr closed 8 months ago

nvjkmr commented 8 months ago

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

Screenshots

Screenshot 2023-11-21 at 10 18 42 PM

Version Information

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 8 months ago

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!