diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index c14bbaeb74..b039069da9 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -835,7 +835,14 @@ module Homebrew kegs = Keg.all deleted_formulae = kegs.map do |keg| - next if Formulary::FromNameLoader.try_new(keg.name, warn: false).nil? + next if Formulary.tap_paths(keg.name).any? + + unless EnvConfig.no_install_from_api? + # Formulae installed from the API should not count as deleted formulae + # but may not have a tap listed in their tab + tap = Tab.for_keg(keg).tap + next if (tap.blank? || tap.core_tap?) && Homebrew::API::Formula.all_formulae.key?(keg.name) + end keg.name end.compact.uniq diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 49822652b9..015e94d22f 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -1172,6 +1172,18 @@ module Formulary find_formula_in_tap(name.to_s.downcase, CoreTap.instance) end + def self.tap_paths(name) + name = name.to_s.downcase + Tap.map do |tap| + formula_path = find_formula_in_tap(name, tap) + + alias_path = tap.alias_dir/name + next alias_path if !formula_path.exist? && alias_path.exist? + + formula_path + end.select(&:file?) + end + sig { params(name: String, tap: Tap).returns(Pathname) } def self.find_formula_in_tap(name, tap) filename = if name.end_with?(".rb")