diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index 4790d65f8a..6a0e94fdd1 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -134,6 +134,14 @@ module Homebrew nil end + if formula.blank? && formula_name.delete_suffix!("_bottle_manifest") + formula = begin + Formulary.from_rack(HOMEBREW_CELLAR/formula_name) + rescue FormulaUnavailableError, TapFormulaAmbiguityError + nil + end + end + return false if formula.blank? resource_name = basename_str[/\A.*?--(.*?)--?(?:#{Regexp.escape(version.to_s)})/, 1] @@ -328,7 +336,7 @@ module Homebrew def cleanup_formula(formula, quiet: false, ds_store: true, cache_db: true) formula.eligible_kegs_for_cleanup(quiet:) .each(&method(:cleanup_keg)) - cleanup_cache(Pathname.glob(cache/"#{formula.name}--*").map { |path| { path:, type: nil } }) + cleanup_cache(Pathname.glob(cache/"#{formula.name}{_bottle_manifest,}--*").map { |path| { path:, type: nil } }) rm_ds_store([formula.rack]) if ds_store cleanup_cache_db(formula.rack) if cache_db cleanup_lockfiles(FormulaLock.new(formula.name).path)