diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 0ed17b9c04..8f5c19e12f 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -96,6 +96,9 @@ class FormulaInstaller @requirement_messages = [] @poured_bottle = false @start_time = nil + + # Take the original formula instance, which might have been swapped from an API instance to a source instance + @formula = previously_fetched_formula if previously_fetched_formula end def self.attempted @@ -1182,9 +1185,17 @@ on_request: installed_on_request?, options: options) deps.each { |dep, _options| fetch_dependency(dep) } end + sig { returns(T.nilable(Formula)) } + def previously_fetched_formula + # We intentionally don't compare classes here. + self.class.fetched.find do |fetched_formula| + fetched_formula.full_name == formula.full_name && fetched_formula.active_spec_sym == formula.active_spec_sym + end + end + sig { void } def fetch - return if self.class.fetched.include?(formula) + return if previously_fetched_formula fetch_dependencies