ruby / did_you_mean

The gem that has been saving people from typos since 2014

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issues with the did_you_mean deprecation warning

eregon opened this issue · comments

I've noticed rubygems/rubygems#5234 as well.

I think there are multiple improvements here:

  • The warning should show the caller, otherwise it's hard to know which gem is causing it (warn msg, uplevel: 1 does that).
  • Since it's a deprecation warning it would be great to only show it when Warning[:deprecated] Of course that only works on Ruby 2.7+, on other versions probably better to show only if $VERBOSE.
  • (warn msg, category: :deprecated would also work but needs Ruby 3+)

There is also the question whether it's worth at all to warn for this, given the current code handles it just fine by forwarding to the new method.
Having 2 public APIs for the same thing is not ideal, so the warning makes sense for that, but OTOH asking various usages to update just for Ractor support which is likely not used (and would work fine with the old way due to the forwarding) is not ideal either.

I noticed the deprecate_constant :SPELL_CHECKERS so we would get a location if Warning[:deprecated] (non-default on 2.7.2+). So maybe no need to show the caller if we only warn when Warning[:deprecated].

@eregon do you know if it's somehow possible to find the offensive gem currently in the codebase? I'm getting it in the Rails app and I have no idea how to find it, to report it or fix

Maybe running after export RUBYOPT=-W:deprecated helps to find out.

Thanks, I actually found it today. It was caused by old version of thor gem. The old version was enforced by other gem (license_finder). I found it by quick examination of our gem list versions.

FWIW my issue was bundler, upgraded to 2.3.9 and fixed the warning.

Thank you all for all the insights and recommendations. Really appreciate the time you all have taken for the conversation here. With all that said, I don't think this is an issue today. I know people (including me) have run into an awkward situation, but this is a problem time will (or possibly have already solved) solve. If anyone runs into this issue. please refer to rubygems/rubygems#5234 for how to fix it.