From ae457a80286d168b1adf9486f74d12fad503f964 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Sat, 30 Oct 2021 23:54:01 -0400 Subject: [PATCH] Fix loading formulae from core tap --- Library/Homebrew/dependency.rb | 5 ----- Library/Homebrew/formula_installer.rb | 5 +++++ Library/Homebrew/formulary.rb | 7 +++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb index 79874077d5..aa5375112a 100644 --- a/Library/Homebrew/dependency.rb +++ b/Library/Homebrew/dependency.rb @@ -44,11 +44,6 @@ class Dependency formula = Formulary.factory(name) formula.build = BuildOptions.new(options, formula.options) formula - rescue CoreTapFormulaUnavailableError - raise if !Homebrew::EnvConfig.install_from_api? || !Homebrew::API::Bottle.available?(name) - - Homebrew::API::Bottle.fetch_bottles(name) - retry end def unavailable_core_formula? diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 4c3fd9e547..51dc58f2d4 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -212,6 +212,11 @@ class FormulaInstaller def verify_deps_exist begin compute_dependencies + rescue CoreTapFormulaUnavailableError => e + raise unless Homebrew::API::Bottle.available? e.name + + Homebrew::API::Bottle.fetch_bottles(e.name) + retry rescue TapFormulaUnavailableError => e raise if e.tap.installed? || e.tap.core_tap? diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index ed492477a6..768e49bb7e 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -535,6 +535,13 @@ module Formulary when URL_START_REGEX return FromUrlLoader.new(ref) when HOMEBREW_TAP_FORMULA_REGEX + # If `homebrew/core` is specified and not installed, check whether the formula is already installed. + if ref.start_with?("homebrew/core/") && !CoreTap.instance.installed? && Homebrew::EnvConfig.install_from_api? + name = ref.split("/", 3).last + possible_keg_formula = Pathname.new("#{HOMEBREW_PREFIX}/opt/#{name}/.brew/#{name}.rb") + return FormulaLoader.new(name, possible_keg_formula) if possible_keg_formula.file? + end + return TapLoader.new(ref, from: from) end