[Bug Report] bundle exec packwerk init is throwing a Sorbet Type Error
steve-low opened this issue · 3 comments
Description
Running bundle exec packwerk init
is failing while creating application_load_paths due to Sorbet error: Return value: Expected type T::Array[String], got T::Array[T.any(Pathname, String)]
To Reproduce
This may be repo dependent, but running bundle exec packwerk init
failed on the Shopify Flow repo.
Expected Behaviour
No error.
Screenshots
If applicable, add screenshots to help explain your problem.
Version Information
- Packwerk: 1.0.0 & 1.0.1
- Ruby 2.6.5
Additional Context
I found a workaround to get it working and was able to initialize, validate, and execute packwerk checks.
I changed
from:
(engine.config.autoload_paths + engine.config.eager_load_paths + engine.config.autoload_once_paths).uniq
to:
(engine.config.autoload_paths + engine.config.eager_load_paths + engine.config.autoload_once_paths).map(&:to_s).uniq
I can submit a PR with this change if those with more packwerk context think this is the correct change to make.
Thank you for reporting this!
Yeah, the cast to string seems like a workable solution to make the code satisfy the type signature.
I wonder if this changed in Rails, and why this didn't happen in CI
It would be great if you could look at adding a test too.
So it looks like it's not something that changed in Rails, it's a Pathname that's added in the Flow repo. It adds a Pathname to the eager_load_path
here and that's what causes the exception. I'll update the Flow repo to add this Pathname as a String.
I will still open the PR I have ready for packwerk in case it's something that would still be useful to protect against this error. If it's seen as not necessary we can close.
fixed