diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 90acb07743..ef01d0452c 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -78,16 +78,20 @@ module Homebrew extend self unless formulae.empty? perform_preinstall_checks formulae.each do |f| - begin - fi = FormulaInstaller.new(f) - fi.install - fi.caveats - fi.finish - rescue CannotInstallFormulaError => e - ofail e.message - end + install_formula(f) end end end + def install_formula f + fi = FormulaInstaller.new(f) + fi.install + fi.caveats + fi.finish + rescue FormulaInstallationAlreadyAttemptedError + # We already attempted to install f as part of the dependency tree of + # another formula. In that case, don't generate an error, just move on. + rescue CannotInstallFormulaError => e + ofail e.message + end end diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index 06dfb87329..c3a924ec51 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -73,6 +73,9 @@ module Homebrew extend self installer.install installer.caveats installer.finish + rescue FormulaInstallationAlreadyAttemptedError + # We already attempted to upgrade f as part of the dependency tree of + # another formula. In that case, don't generate an error, just move on. rescue CannotInstallFormulaError => e ofail e rescue BuildError => e diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index db54f9d602..66d0827cd0 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -24,6 +24,10 @@ class FormulaInstaller end def check_install_sanity + @@attempted ||= Set.new + raise FormulaInstallationAlreadyAttemptedError, f if @@attempted.include? f + @@attempted << f + if f.installed? msg = "#{f}-#{f.installed_version} already installed" msg << ", it's just not linked" if not f.linked_keg.symlink? and not f.keg_only? @@ -112,10 +116,6 @@ class FormulaInstaller oh1 "Installing #{f}" if show_header - @@attempted ||= Set.new - raise FormulaInstallationAlreadyAttemptedError, f if @@attempted.include? f - @@attempted << f - if install_bottle pour else