Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package rubygem-zeitwerk for openSUSE:Factory checked in at 2021-12-29 21:10:59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-zeitwerk (Old) and /work/SRC/openSUSE:Factory/.rubygem-zeitwerk.new.2520 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-zeitwerk" Wed Dec 29 21:10:59 2021 rev:10 rq:943007 version:2.5.2 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-zeitwerk/rubygem-zeitwerk.changes 2021-12-22 20:19:09.743877867 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-zeitwerk.new.2520/rubygem-zeitwerk.changes 2021-12-29 21:11:30.206312499 +0100 @@ -1,0 +2,11 @@ +Wed Dec 29 01:18:19 UTC 2021 - Manuel Schnitzer <mschnit...@suse.com> + +- updated to version 2.5.2 + + * When `Module#autoload` triggers the autovivification of an implicit + namespace, `$LOADED_FEATURES` now gets the correspoding directory + pushed. This is just a tweak to Zeitwerk's `Kernel#require` decoration. + That way it acts more like the original, and cooperates better with + other potential `Kernel#require` wrappers, like Bootsnap's. + +------------------------------------------------------------------- Old: ---- zeitwerk-2.5.1.gem New: ---- zeitwerk-2.5.2.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-zeitwerk.spec ++++++ --- /var/tmp/diff_new_pack.pU3yp3/_old 2021-12-29 21:11:30.670312881 +0100 +++ /var/tmp/diff_new_pack.pU3yp3/_new 2021-12-29 21:11:30.674312884 +0100 @@ -24,7 +24,7 @@ # Name: rubygem-zeitwerk -Version: 2.5.1 +Version: 2.5.2 Release: 0 %define mod_name zeitwerk %define mod_full_name %{mod_name}-%{version} ++++++ zeitwerk-2.5.1.gem -> zeitwerk-2.5.2.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2021-10-21 00:00:32.000000000 +0200 +++ new/README.md 2021-12-27 13:00:43.000000000 +0100 @@ -50,8 +50,8 @@ - [Rules of thumb](#rules-of-thumb) - [Debuggers](#debuggers) - [debug.rb](#debugrb) - - [Break](#break) - [Byebug](#byebug) + - [Break](#break) - [Pronunciation](#pronunciation) - [Supported Ruby versions](#supported-ruby-versions) - [Testing](#testing) @@ -810,7 +810,9 @@ end ``` -That file does not define a constant path after the path name and you need to tell Zeitwerk: +`Kernel` is already defined by Ruby so the module cannot be autoloaded. Also, that file does not define a constant path after the path name. Therefore, Zeitwerk should not process it at all. + +The extension can still coexist with the rest of the project, you only need to tell Zeitwerk to ignore it: ```ruby kernel_ext = "#{__dir__}/my_gem/core_ext/kernel.rb" @@ -826,6 +828,14 @@ loader.setup ``` +Now, that file has to be loaded manually with `require` or `require_relative`: + +```ruby +require_relative "my_gem/core_ext/kernel" +``` + +and you can do that anytime, before configuring the loader, or after configuring the loader, does not matter. + <a id="markdown-use-case-the-adapter-pattern" name="use-case-the-adapter-pattern"></a> #### Use case: The adapter pattern @@ -973,17 +983,19 @@ <a id="markdown-debugrb" name="debugrb"></a> #### debug.rb -The new [debug.rb](https://github.com/ruby/debug) gem and Zeitwerk seem to be compatible, as far as I can tell. This is the new debugger that is going to ship with Ruby 3.1. +The new [debug.rb](https://github.com/ruby/debug) gem and Zeitwerk are mostly compatible. This is the new debugger that is going to ship with Ruby 3.1. -<a id="markdown-break" name="break"></a> -#### Break - -Zeitwerk works fine with [@gsamokovarov](https://github.com/gsamokovarov)'s [Break](https://github.com/gsamokovarov/break) debugger. +There's one exception, though: Due to a technical limitation of tracepoints, explicit namespaces are not autoloaded while expressions are evaluated in the REPL. See [ruby/debug#408](https://github.com/ruby/debug/issues/408). <a id="markdown-byebug" name="byebug"></a> #### Byebug -Zeitwerk and [Byebug](https://github.com/deivid-rodriguez/byebug) are incompatible, classes or modules that belong to [explicit namespaces](#explicit-namespaces) are not autoloaded inside a Byebug session. See [this issue](https://github.com/deivid-rodriguez/byebug/issues/564#issuecomment-499413606) for further details. +Zeitwerk and [Byebug](https://github.com/deivid-rodriguez/byebug) have a similar edge incompatibility. + +<a id="markdown-break" name="break"></a> +#### Break + +Zeitwerk works fine with [@gsamokovarov](https://github.com/gsamokovarov)'s [Break](https://github.com/gsamokovarov/break) debugger. <a id="markdown-pronunciation" name="pronunciation"></a> ## Pronunciation Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/zeitwerk/kernel.rb new/lib/zeitwerk/kernel.rb --- old/lib/zeitwerk/kernel.rb 2021-10-21 00:00:32.000000000 +0200 +++ new/lib/zeitwerk/kernel.rb 2021-12-27 13:00:43.000000000 +0100 @@ -24,22 +24,23 @@ def require(path) if loader = Zeitwerk::Registry.loader_for(path) if path.end_with?(".rb") - zeitwerk_original_require(path).tap do |required| - loader.on_file_autoloaded(path) if required - end + required = zeitwerk_original_require(path) + loader.on_file_autoloaded(path) if required + required else loader.on_dir_autoloaded(path) + $LOADED_FEATURES << path true end else - zeitwerk_original_require(path).tap do |required| - if required - abspath = $LOADED_FEATURES.last - if loader = Zeitwerk::Registry.loader_for(abspath) - loader.on_file_autoloaded(abspath) - end + required = zeitwerk_original_require(path) + if required + abspath = $LOADED_FEATURES.last + if loader = Zeitwerk::Registry.loader_for(abspath) + loader.on_file_autoloaded(abspath) end end + required end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/zeitwerk/loader.rb new/lib/zeitwerk/loader.rb --- old/lib/zeitwerk/loader.rb 2021-10-21 00:00:32.000000000 +0200 +++ new/lib/zeitwerk/loader.rb 2021-12-27 13:00:43.000000000 +0100 @@ -1,7 +1,6 @@ # frozen_string_literal: true require "set" -require "securerandom" module Zeitwerk class Loader @@ -124,13 +123,7 @@ # @sig () -> void def unload mutex.synchronize do - # We are going to keep track of the files that were required by our - # autoloads to later remove them from $LOADED_FEATURES, thus making them - # loadable by Kernel#require again. - # - # Directories are not stored in $LOADED_FEATURES, keeping track of files - # is enough. - unloaded_files = Set.new + abspaths_of_unloaded_crefs = Set.new autoloads.each do |abspath, (parent, cname)| if parent.autoload?(cname) @@ -140,7 +133,7 @@ # and the constant path would escape unloadable_cpath? This is just # defensive code to clean things up as much as we are able to. unload_cref(parent, cname) - unloaded_files.add(abspath) if ruby?(abspath) + abspaths_of_unloaded_crefs.add(abspath) end end @@ -151,10 +144,14 @@ end unload_cref(parent, cname) - unloaded_files.add(abspath) if ruby?(abspath) + abspaths_of_unloaded_crefs.add(abspath) end - unless unloaded_files.empty? + unless abspaths_of_unloaded_crefs.empty? + # We remove these abspaths from $LOADED_FEATURES because, otherwise, + # `require`'s idempotence would prevent newly defined autoloads from + # loading them again. + # # Bootsnap decorates Kernel#require to speed it up using a cache and # this optimization does not check if $LOADED_FEATURES has the file. # @@ -166,7 +163,7 @@ # Rails applications may depend on bootsnap, so for unloading to work # in that setting it is preferable that we restrict our API choice to # one of those methods. - $LOADED_FEATURES.reject! { |file| unloaded_files.member?(file) } + $LOADED_FEATURES.reject! { |file| abspaths_of_unloaded_crefs.member?(file) } end autoloads.clear diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/zeitwerk/version.rb new/lib/zeitwerk/version.rb --- old/lib/zeitwerk/version.rb 2021-10-21 00:00:32.000000000 +0200 +++ new/lib/zeitwerk/version.rb 2021-12-27 13:00:43.000000000 +0100 @@ -1,5 +1,5 @@ # frozen_string_literal: true module Zeitwerk - VERSION = "2.5.1" + VERSION = "2.5.2" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2021-10-21 00:00:32.000000000 +0200 +++ new/metadata 2021-12-27 13:00:43.000000000 +0100 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: zeitwerk version: !ruby/object:Gem::Version - version: 2.5.1 + version: 2.5.2 platform: ruby authors: - Xavier Noria autorequire: bindir: bin cert_chain: [] -date: 2021-10-20 00:00:00.000000000 Z +date: 2021-12-27 00:00:00.000000000 Z dependencies: [] description: |2 Zeitwerk implements constant autoloading with Ruby semantics. Each gem