From 9a356fc6091a7343f5e4db6c9660e04aa08c716c Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Fri, 31 Oct 2014 18:33:39 -0500 Subject: [PATCH] Remove FormulaAlreadyInstalledError install is the only command that can trigger this warning, so it should be handled before instantiating the installer. --- Library/Homebrew/cmd/install.rb | 14 +++++++++++--- Library/Homebrew/cmd/reinstall.rb | 2 -- Library/Homebrew/exceptions.rb | 2 -- Library/Homebrew/formula_installer.rb | 6 ------ 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 16efadff4b..00be1a2f56 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -25,6 +25,8 @@ module Homebrew end unless ARGV.force? begin + formulae = [] + ARGV.formulae.each do |f| # Building head-only without --HEAD is an error if not ARGV.build_head? and f.stable.nil? @@ -38,11 +40,19 @@ module Homebrew if ARGV.build_head? and f.head.nil? raise "No head is defined for #{f.name}" end + + if f.installed? + msg = "#{f.name}-#{f.installed_version} already installed" + msg << ", it's just not linked" unless f.linked_keg.symlink? or f.keg_only? + opoo msg + else + formulae << f + end end perform_preinstall_checks - ARGV.formulae.each { |f| install_formula(f) } + formulae.each { |f| install_formula(f) } rescue FormulaUnavailableError => e ofail e.message query = query_regexp(e.name) @@ -126,8 +136,6 @@ module Homebrew 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 FormulaAlreadyInstalledError => e - opoo e.message rescue CannotInstallFormulaError => e ofail e.message check_macports diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb index b72fbad091..2ac1114d89 100644 --- a/Library/Homebrew/cmd/reinstall.rb +++ b/Library/Homebrew/cmd/reinstall.rb @@ -31,8 +31,6 @@ module Homebrew fi.finish rescue FormulaInstallationAlreadyAttemptedError # next - rescue FormulaAlreadyInstalledError => e - opoo e.message rescue Exception ignore_interrupts { restore_backup(keg, f) } raise diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 100effdbd7..d938b52e2b 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -81,8 +81,6 @@ end class CannotInstallFormulaError < RuntimeError; end -class FormulaAlreadyInstalledError < RuntimeError; end - class FormulaInstallationAlreadyAttemptedError < RuntimeError def initialize(formula) super "Formula installation already attempted: #{formula.name}" diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 6a2c27a350..1e07bdbaa0 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -104,12 +104,6 @@ class FormulaInstaller def check_install_sanity raise FormulaInstallationAlreadyAttemptedError, formula if @@attempted.include?(formula) - if formula.installed? - msg = "#{formula.name}-#{formula.installed_version} already installed" - msg << ", it's just not linked" unless formula.linked_keg.symlink? or formula.keg_only? - raise FormulaAlreadyInstalledError, msg - end - unless ignore_deps? unlinked_deps = formula.recursive_dependencies.map(&:to_formula).select do |dep| dep.installed? and not dep.keg_only? and not dep.linked_keg.directory?