From 096a5bdfb431b366d9a67340366195e805efc748 Mon Sep 17 00:00:00 2001 From: Steven Peters Date: Sat, 21 Mar 2020 02:49:17 -0700 Subject: [PATCH] FormulaInstaller: link tmp kegs during rescue In #6807, the FormulaInstaller began to rescue from FormulaInstallationAlreadyAttemptedError but there is the potential for tmp kegs to remain unlinked in the cellar. I've merged the rescue statements so they both re-link tmp kegs, but it doesn't raise for FormulaInstallationAlreadyAttemptedError. --- Library/Homebrew/formula_installer.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 0cc5470bcb..e070a466c3 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -598,16 +598,16 @@ class FormulaInstaller oh1 "Installing #{formula.full_name} dependency: #{Formatter.identifier(dep.name)}" fi.install fi.finish - rescue FormulaInstallationAlreadyAttemptedError - # We already attempted to install f as part of the dependency tree of - # another formula. In that case, don't generate an error, just move on. - nil - rescue Exception # rubocop:disable Lint/RescueException + rescue Exception => e # rubocop:disable Lint/RescueException ignore_interrupts do tmp_keg.rename(installed_keg) if tmp_keg && !installed_keg.directory? linked_keg.link if keg_was_linked end - raise + raise unless e.is_a? FormulaInstallationAlreadyAttemptedError + + # We already attempted to install f as part of another formula's + # dependency tree. In that case, don't generate an error, just move on. + nil else ignore_interrupts { tmp_keg.rmtree if tmp_keg&.directory? } end