aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorMike McQuaid2017-02-21 21:29:32 +0000
committerMike McQuaid2017-02-21 21:29:32 +0000
commit42bb19a6317172804cd149024115f6973fa2fd4f (patch)
tree58c6dbc54cf63f2ba1c2f206cbd60d7249e6d5dd /Library/Homebrew
parented7290abb4b5a6820c30cd10b141a7713d932fd6 (diff)
downloadbrew-42bb19a6317172804cd149024115f6973fa2fd4f.tar.bz2
formula_installer: detect recursive dependencies.
Detect recursive dependencies and refuse to install them providing instruction on exactly what is depending on what. Fixes #1933.
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/formula_installer.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index c9f478bb1..1f91ad5c4 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -151,6 +151,28 @@ class FormulaInstaller
recursive_deps = formula.recursive_dependencies
recursive_formulae = recursive_deps.map(&:to_formula)
+ recursive_dependencies = []
+ recursive_formulae.each do |dep|
+ dep_recursive_dependencies = dep.recursive_dependencies.map(&:to_s)
+ if dep_recursive_dependencies.include?(formula.name)
+ recursive_dependencies << "#{formula.full_name} depends on #{dep.full_name}"
+ recursive_dependencies << "#{dep.full_name} depends on #{formula.full_name}"
+ end
+ end
+
+ unless recursive_dependencies.empty?
+ raise CannotInstallFormulaError, <<-EOS.undent
+ #{formula.full_name} contains a recursive dependency on itself:
+ #{recursive_dependencies.join("\n ")}
+ EOS
+ end
+
+ if recursive_formulae.flat_map(&:recursive_dependencies).map(&:to_s).include?(formula.name)
+ raise CannotInstallFormulaError, <<-EOS.undent
+ #{formula.full_name} contains a recursive dependency on itself!
+ EOS
+ end
+
if ENV["HOMEBREW_CHECK_RECURSIVE_VERSION_DEPENDENCIES"]
version_hash = {}
version_conflicts = Set.new