Need help with packwerk gem privacy and dependency violations for custom folder structure

This message was imported from the Ruby/Rails Modularity Slack server. Find more info in the import thread.

Message originally sent by slack user U71TN2WF04X

Hi! I don’t know where I should ask this, hope this is the right place.
I have a custom folder like this app/custom_folder in which I will have files of the same type, all inheriting from a base class.
I have the base class defined on packs/base/app/custom_folder/base.rb and then on another pack I have the one that inherits from it packs/other/app/custom_folder/inherits.rb
Some code might make this easier:

# packs/base/app/custom_folder/base.rb

class Base
  # Whatever
end
# packs/other/app/custom_folder/inherits.rb

class Inherits < Base # <- Should be a violation
  # Whatever
end

But when I execute bin/packwerk check --packages=packs/other I don’t get a privacy or dependency violation from this behaviour, should I be adding this app/custom_folder path to some config for it to work?

You are correct to expect that this usage of Base should be picked up by packwerk. I just tried it in a version of Sportsball and it does indeed work as you expect.

Next steps to take: Make sure your app and these classes work as expected. Make sure all enforcements are turned on. After that, I’d fiddle with the names: make them unique to make really sure it is not some other constant that gets picked up by packwerk

Message originally sent by slack user U71TN2WF04X

Then it must be something wrong on my behalf :+1:
I will start it from scratch since it has grown a lot the base pack! Thanks!

also: never call a pack base.

It is only destined to be junk drawer

Message originally sent by slack user U71TN2WF04X

Found my error, my base class is under lib/base.rb and the one that inherits is under app/custom_folder/inherits.rb, if I move the base to the same structure then it works as expected.

Aggred with the naming, it was just to avoid going into detail that is not needed to solve my problem :wink: