fxn / zeitwerk

Efficient and thread-safe code loader for Ruby
MIT License
1.99k stars 118 forks source link

Ruby 3.4.0 no longer includes "abbrev" and it suggests zeitwerk to include it #289

Closed everton closed 7 months ago

everton commented 7 months ago

Ruby 3.3.0 is presenting this warning while loading a Rails application:

abbrev was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. 
Add abbrev to your Gemfile or gemspec.

Also **contact author of zeitwerk-2.6.13 to add abbrev into its gemspec.**

The lib is now available as a gem maintained by Ruby team: https://github.com/ruby/abbrev

But I can't see any direct usage of the lib inside the project, so I think this is caused by dependencies loaded through zeitwerk, which leads to another problem (if this is the case): how can I tell what exactly is causing this?

I opened this issue here cause I don't know how I can find where is the proper repo to open it, feel free to close it, of course, but it would be great if:

  1. you contact Ruby team to present a better warning in this case, if this is possible, of course
  2. suggest how can one know what is causing this deprecation, if it is not your gem directly

Thanks!

everton commented 7 months ago

debugging the callers for the abbrev inside the gem, I was able to find the cause in my case; it was the Highline gem, and they are already looking for this issue:

https://github.com/JEG2/highline/issues/270

I will not close the issue here now because I am still curious: is there any way that Ruby or Zeitwerk could improve this warning to point to the gem causing the warning? I mean, probably other similar cases will happen with other gems, and it seems interesting to know what the cause is without the need to debug from inside Zeitwerk code, but I really don't know if Ruby has the resources to instrument this.

fxn commented 7 months ago

Hi @everton.

Indeed, this is the 5th issue that is opened for the same reason.

Zeitwerk decorates Kernel#require and Ruby issues a warning that basically assumes nobody is decorating that method. But this assumption is incorrect, since a few gems do, and Ruby modules are open by design anyway.

We are discussing here https://github.com/ruby/ruby/pull/10244.