This message was imported from the Ruby/Rails Modularity Slack server. Find more info in the import thread.
Message originally sent by slack user U70DMI6W1TM
Hmm, we just upgraded one of our applications to Ruby 3.1.2, and packwerk validate
is breaking:
vendor/bundle/ruby/3.1.0/gems/activesupport-6.1.4.6/lib/active_support/inflector/methods.rb:286:in `const_get': uninitialized constant PrivateThing (NameError)
constant.const_get(name)
Anyone else seen this?
Hey I haven’t seen this — is it still breaking for you? Are you able to isolate a reproduction?
Message originally sent by slack user U70DMI6W1TM
Oh, sorry, should have followed up here. I didn’t find a minimal repro, but I was able to find a workaround. We already had an exclude
directive in packwerk.yml
:
exclude:
- "services/**/spec/**/*"
(“services” are our packages). Adding "vendor/**/*"
to the exclude list silenced the error, which I take to mean that validate
was somehow reviewing our bundled gems as well as what we’d explicitly told it to look at:
include:
- "services/**/*.{rb,rake,erb}"
- "app/**/*.{rb,rake,erb}"
Glad you found a workaround! I suspect what is going on is packwerk is reading itself (PrivateThing) and erroring since your application doesn’t have that constant.
If this is correct, it’s because you haven’t set package_paths
, which defaults to **/, which makes it include that package.yml
with the invalid entry. I don’t think include
is used to find package_paths
. Rather, include
is for what files to parse and exclude
excludes files from both parsing and package paths. (A little confusing IMO.)
Message originally sent by slack user U70DMI6W1TM
Ah, interesting! You’re right that we haven’t overridden package_paths
. And also that the lack of similarity between include
and exclude
is confusing and/or surprising
Thanks!
Message originally sent by slack user U70DMI6W1TM
Hmm, just tried switch from exclude
to package_paths
and it’s still trying to load the package.yml
from Packwerk itself
Message originally sent by slack user U70DMI6W1TM
Oh, nope, typo’d – it works. Thanks again!