From 22c3b2387a77669212d93899e315ac298239ba70 Mon Sep 17 00:00:00 2001 From: Nick Logan Date: Sun, 24 May 2026 16:27:27 -0700 Subject: [PATCH] Handle missing CompUnit::Repository::Staging Failure The `!~~ Failure` check in #617 distinguishes loaded vs missing symbol, but smartmatch doesn't mark the Failure handled, so DESTROY warns about the unhandled missing-symbol Failure on every install when the class isn't loaded (i.e. every install today). Restructure as `do given` with a `when Failure` arm so the Failure is dispatched on as a topic and marked handled inside the load-by-path fallback. --- lib/Zef/Client.rakumod | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/Zef/Client.rakumod b/lib/Zef/Client.rakumod index 41ad3c27..5de7ab22 100644 --- a/lib/Zef/Client.rakumod +++ b/lib/Zef/Client.rakumod @@ -1076,9 +1076,10 @@ class Zef::Client { # for instance). my %curfs-new-args = :prefix($staging-at), :name($stage-for-repo.name), :next-repo($stage-for-repo); my $curfs-short-name = 'CompUnit::Repository::Staging'; - (::($curfs-short-name) !~~ Failure) - ?? ::($curfs-short-name).new(|%curfs-new-args) - !! do { + my $curfs-class := do given ::($curfs-short-name) { + when Failure { + .handled = True; + # Find CURS from the core repository so we can load it by path later my $core-repo = CompUnit::RepositoryRegistry.repository-for-name('core'); my $curs-dist = $core-repo.resolve(CompUnit::DependencySpecification.new(:short-name($curfs-short-name))).distribution; @@ -1089,8 +1090,11 @@ class Zef::Client { my $curs-handle = $curs-dist.content($curs-name-path); $curs-handle.close(); # I think these handles shouldn't be opened already from ::InstalledDistribution :( $*REPO.load($curs-handle.path); - ::($curfs-short-name).new(|%curfs-new-args); + ::($curfs-short-name); } + default { $_ } + } + $curfs-class.new(|%curfs-new-args); } # Staging workflow