fxn/zeitwerk

Deprecation message coming from zeitwerk

ngan opened this issue · 2 comments

ngan commented

I recently noticed a deprecation message in our builds:

DEPRECATION WARNING: /usr/local/bundle/ruby/3.3.0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38: warning: nkf was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add nkf to your Gemfile or gemspec. Also contact author of zeitwerk-2.6.12 to add nkf into its gemspec.
  | (called from <top (required)> at /usr/local/bundle/ruby/3.3.0/gems/mechanize-2.9.1/lib/mechanize/util.rb:3)

After carefully reading the message, you can see that the call came from mechanize (which is fixed in the most recent version). But I figured I'd just put up an issue to let you know about this misleading message:

Add nkf to your Gemfile or gemspec. Also contact author of zeitwerk-2.6.12 to add nkf into its gemspec.

Not sure if it's fixable or where the fix should be. Looks like the message is coming from here.

As always, thanks for great work @fxn!

fxn commented

Thanks for opening the issue, it will help other people facing the same warning. And it will help me have a model to point to in forthcoming warning reports :).

I don't think Zeitwerk can do anything to silence it because, as you correctly pointed out, it is emitted by Ruby out-of-band. Basically, Zeitwerk has a thin decorator around Kernel#require (here), and the logic around the warning message is not able to distinguish this as of today.

fxn commented

For future visitors of this ticket.

Zeitwerk is not the real source of the warning. See the "called from" in the ticket description above? You need to figure out who is depending on the gem for real up in the call stack.