diff options
| author | Mike McQuaid | 2016-12-13 00:37:40 +0000 |
|---|---|---|
| committer | Mike McQuaid | 2016-12-13 00:37:40 +0000 |
| commit | 961b5fff9d4426a1b53da332c8016dcd61eae48a (patch) | |
| tree | 2de37706d37ebb5b2f26972cdd6d85c0fe25544d /Library | |
| parent | 666463ca2be08261cf103e4870b267f5b461a7f3 (diff) | |
| download | brew-961b5fff9d4426a1b53da332c8016dcd61eae48a.tar.bz2 | |
formula_installer: prevent version mismatched deps
Don't allow e.g. the use of `openssl` and `openssl@1.1` in the same
dependency tree to avoid runtime failures and general weirdness.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/formula_installer.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index bd1cc9379..c701aeb39 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -146,7 +146,23 @@ class FormulaInstaller return if ignore_deps? recursive_deps = formula.recursive_dependencies - unlinked_deps = recursive_deps.map(&:to_formula).select do |dep| + recursive_formulae = recursive_deps.map(&:to_formula) + + version_hash = {} + version_conflicts = Set.new + recursive_formulae.each do |f| + name = f.name + unversioned_name, = name.split("@") + version_hash[unversioned_name] ||= Set.new + version_hash[unversioned_name] << name + next if version_hash[unversioned_name].length < 2 + version_conflicts += version_hash[unversioned_name] + end + unless version_conflicts.empty? + raise CannotInstallFormulaError, "#{formula.full_name} contains conflicting version dependencies (#{version_conflicts.to_a.join " "}) so cannot be installed" + end + + unlinked_deps = recursive_formulae.select do |dep| dep.installed? && !dep.keg_only? && !dep.linked_keg.directory? end |
