good_job: Upgrading zeitwerk to 2.6.0 causes a warning related to good_job
Hi @bensheldon
Today I upgraded zeitwerk
to v. 2.6.0
. Running my testsuite now produces
WARNING: Zeitwerk defines the constant ActiveJob after the directory
/Users/jgrau/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/good_job-2.15.1/lib/active_job
To prevent that, please configure the loader to ignore it:
loader.ignore("#{__dir__}/active_job")
Otherwise, there is a flag to silence this warning:
Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
The zeitwerk changelog describes the warning. It probably makes more sense to you than to me 😉
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 7
- Comments: 22 (9 by maintainers)
@fxn thank you for that 🙏 I deployed the version with the ignore+push_dir. I guess in my mental model of Zeitwerk I’m opting out of the default code-loading algorithm, and then declaring a special-purpose one.
@fxn hmmm. I don’t really like mixing auto and manually nested constants in the same
good_job
directory. I worry I’ll forget the reason why and violate my own principle of least surprise at some point in the future.I think I prefer doing both
ignore
andpush_dir
-with-namepace because they are clearest to me of what’s happening and they keep the constants nested consistently without exception.@bensheldon I like this one even as a replacement for the documentation, because it forces the user to
require
the namespace beforehand or it won’t work.EDIT: Actually no, when I read the snippet I didn’t realize it was ignoring
active_job
. This configuration should not even work the way it does now, because you have active code within an ignored directory.This also seems to work as a workaround. I worry that implying to Zeitwerk that “I know what I’m doing” with
warn_on_extra_files: true
is hubris 😓