Don't attempt installation multiple times
When a dependency of a formula specified on the command-line is also specified, *after* the dependent formula, installation proceeds as part of the dependent's dependency tree and then is attempted again because the user asked for it explicitly. This results in the installer raising a CannotInstallFormulaError because it has already been installed. For example: $ brew install graphviz pkg-config ==> Installing graphviz dependency: pkg-config ... ==> Installing graphviz ... Error: pkg-config-0.27.1 already installed We already have a mechanism for dealing with this, but it does not kick in early enough. Move the installation attempt check into FormulaInstaller#check_install_sanity and catch the exception in the appropriate places. Fixes Homebrew/homebrew#16957.
This commit is contained in:
parent
4291bc29db
commit
5c799ef8c8
@ -78,16 +78,20 @@ module Homebrew extend self
|
|||||||
unless formulae.empty?
|
unless formulae.empty?
|
||||||
perform_preinstall_checks
|
perform_preinstall_checks
|
||||||
formulae.each do |f|
|
formulae.each do |f|
|
||||||
begin
|
install_formula(f)
|
||||||
fi = FormulaInstaller.new(f)
|
|
||||||
fi.install
|
|
||||||
fi.caveats
|
|
||||||
fi.finish
|
|
||||||
rescue CannotInstallFormulaError => e
|
|
||||||
ofail e.message
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
@ -73,6 +73,9 @@ module Homebrew extend self
|
|||||||
installer.install
|
installer.install
|
||||||
installer.caveats
|
installer.caveats
|
||||||
installer.finish
|
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
|
rescue CannotInstallFormulaError => e
|
||||||
ofail e
|
ofail e
|
||||||
rescue BuildError => e
|
rescue BuildError => e
|
||||||
|
@ -24,6 +24,10 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
|
|
||||||
def check_install_sanity
|
def check_install_sanity
|
||||||
|
@@attempted ||= Set.new
|
||||||
|
raise FormulaInstallationAlreadyAttemptedError, f if @@attempted.include? f
|
||||||
|
@@attempted << f
|
||||||
|
|
||||||
if f.installed?
|
if f.installed?
|
||||||
msg = "#{f}-#{f.installed_version} already 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?
|
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
|
oh1 "Installing #{f}" if show_header
|
||||||
|
|
||||||
@@attempted ||= Set.new
|
|
||||||
raise FormulaInstallationAlreadyAttemptedError, f if @@attempted.include? f
|
|
||||||
@@attempted << f
|
|
||||||
|
|
||||||
if install_bottle
|
if install_bottle
|
||||||
pour
|
pour
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user