From 139fef8e7456f14ff1517bfbcf0ac31cffc7c64c Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 5 Jul 2018 20:51:44 +0100 Subject: [PATCH] formula_installer: correctly handle build dep reqs. When a build dependency has a requirement it should be ignored when checking for valid requirements. This requires calculating the dependencies for a formula again and checking them when calculating which requirements should be pruned. --- Library/Homebrew/formula_installer.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index f8106340ca..9b1e7a00b2 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -436,8 +436,12 @@ class FormulaInstaller def expand_requirements unsatisfied_reqs = Hash.new { |h, k| h[k] = [] } - deps = [] + req_deps = [] formulae = [formula] + formula_deps_map = Dependency.expand(formula) + .each_with_object({}) do |dep, hash| + hash[dep.name] = dep + end while f = formulae.pop runtime_requirements = runtime_requirements(f) @@ -453,6 +457,8 @@ class FormulaInstaller next elsif !runtime_requirements.include?(req) && install_bottle_for_dependent Requirement.prune + elsif (dep = formula_deps_map[dependent.name]) && dep.build? + Requirement.prune else unsatisfied_reqs[dependent] << req end @@ -460,9 +466,9 @@ class FormulaInstaller end # Merge the repeated dependencies, which may have different tags. - deps = Dependency.merge_repeats(deps) + req_deps = Dependency.merge_repeats(req_deps) - [unsatisfied_reqs, deps] + [unsatisfied_reqs, req_deps] end def expand_dependencies(deps)