From 3d5b4af523dca55fe7fa49433eec2519254b060b Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 16 Mar 2012 11:55:30 +0000 Subject: [PATCH] Tell the user to tap (if req.) for tapped deps Also propagate dependency info through exception if possible so the error message is more useful. --- Library/Homebrew/exceptions.rb | 16 +++++++++++++++- Library/Homebrew/formula_installer.rb | 6 ++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 0d55336d1e..f577ecae5f 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -24,10 +24,24 @@ end class FormulaUnavailableError < RuntimeError attr :name + attr :dependent, true + + def dependent_s + "(dependency of #{dependent})" if dependent and dependent != name + end + + def to_s + if name =~ %r{(\w+)/(\w+)/(\w+)} then <<-EOS.undent + No available formula for #$3 #{dependent_s} + Please tap it and then try again: brew tap #$1/#$2 + EOS + else + "No available formula for #{name} #{dependent_s}" + end + end def initialize name @name = name - super "No available formula for #{name}" end end diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 96dae5bac7..76618ad0c2 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -44,6 +44,12 @@ class FormulaInstaller raise CannotInstallFormulaError, "You must `brew link #{dep}' before #{f} can be installed" end end unless ignore_deps + + rescue FormulaUnavailableError => e + # this is sometimes wrong if the dependency chain is more than one deep + # but can't easily fix this without a rewrite FIXME-brew2 + e.dependent = f.name + raise end def install