2011-03-12 23:06:45 -08:00
|
|
|
class UsageError < RuntimeError; end
|
|
|
|
class FormulaUnspecifiedError < UsageError; end
|
|
|
|
class KegUnspecifiedError < UsageError; end
|
2010-09-11 20:22:54 +01:00
|
|
|
|
2011-03-12 23:06:45 -08:00
|
|
|
class MultipleVersionsInstalledError < RuntimeError
|
2010-11-12 20:59:53 -08:00
|
|
|
attr :name
|
|
|
|
|
|
|
|
def initialize name
|
|
|
|
@name = name
|
|
|
|
super "#{name} has multiple installed versions"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class NotAKegError < RuntimeError; end
|
|
|
|
|
2011-03-12 23:06:45 -08:00
|
|
|
class NoSuchKegError < RuntimeError
|
2010-11-12 20:59:53 -08:00
|
|
|
attr :name
|
|
|
|
|
|
|
|
def initialize name
|
|
|
|
@name = name
|
|
|
|
super "No such keg: #{HOMEBREW_CELLAR}/#{name}"
|
|
|
|
end
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
class FormulaUnavailableError < RuntimeError
|
|
|
|
attr :name
|
2012-03-16 11:55:30 +00:00
|
|
|
attr :dependent, true
|
|
|
|
|
|
|
|
def dependent_s
|
|
|
|
"(dependency of #{dependent})" if dependent and dependent != name
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
2012-03-17 00:20:37 +00:00
|
|
|
if name =~ %r{(\w+)/(\w+)/([^/]+)} then <<-EOS.undent
|
2012-03-16 11:55:30 +00:00
|
|
|
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
|
2010-11-12 20:59:53 -08:00
|
|
|
|
2010-09-11 20:22:54 +01:00
|
|
|
def initialize name
|
|
|
|
@name = name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module Homebrew
|
|
|
|
class InstallationError < RuntimeError
|
|
|
|
attr :formula
|
2010-11-12 20:59:53 -08:00
|
|
|
|
2011-03-09 21:01:23 -08:00
|
|
|
def initialize formula, message=""
|
2010-09-11 20:22:54 +01:00
|
|
|
super message
|
|
|
|
@formula = formula
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-03-07 11:16:27 +00:00
|
|
|
class CannotInstallFormulaError < RuntimeError
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
class FormulaInstallationAlreadyAttemptedError < Homebrew::InstallationError
|
|
|
|
def message
|
|
|
|
"Formula installation already attempted: #{formula}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-02-28 19:56:35 -08:00
|
|
|
class UnsatisfiedRequirement < Homebrew::InstallationError
|
|
|
|
attr :dep
|
2011-03-26 10:19:03 -07:00
|
|
|
|
2012-02-28 19:56:35 -08:00
|
|
|
def initialize formula, dep
|
|
|
|
@dep = dep
|
|
|
|
super formula, "An unsatisfied requirement failed this build."
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class BuildError < Homebrew::InstallationError
|
|
|
|
attr :exit_status
|
|
|
|
attr :command
|
|
|
|
attr :env
|
|
|
|
|
|
|
|
def initialize formula, cmd, args, es
|
|
|
|
@command = cmd
|
|
|
|
@env = ENV.to_hash
|
|
|
|
@exit_status = es.exitstatus rescue 1
|
2011-03-14 15:48:35 -07:00
|
|
|
args = args.map{ |arg| arg.to_s.gsub " ", "\\ " }.join(" ")
|
2010-09-11 20:22:54 +01:00
|
|
|
super formula, "Failed executing: #{command} #{args}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def was_running_configure?
|
|
|
|
@command == './configure'
|
|
|
|
end
|
2012-03-07 11:11:05 +00:00
|
|
|
|
|
|
|
def dump
|
|
|
|
e = self
|
|
|
|
|
|
|
|
require 'cmd/--config'
|
|
|
|
require 'cmd/--env'
|
|
|
|
|
|
|
|
e.backtrace[1] =~ %r{Library/Formula/(.+)\.rb:(\d+)}
|
|
|
|
formula_name = $1
|
|
|
|
error_line = $2
|
|
|
|
|
2012-03-05 16:36:57 +00:00
|
|
|
path = HOMEBREW_REPOSITORY/"Library/Formula/#{formula_name}.rb"
|
|
|
|
if path.symlink? and path.realpath.to_s =~ %r{^#{HOMEBREW_REPOSITORY}/Library/Taps/(\w+)-(\w+)/}
|
|
|
|
repo = "#$1/homebrew-#$2"
|
|
|
|
repo_path = path.realpath.relative_path_from(HOMEBREW_REPOSITORY/"Library/Taps/#$1-#$2").parent.to_s
|
|
|
|
issues_url = "https://github.com/#$1/homebrew-#$2/issues/new"
|
|
|
|
else
|
|
|
|
repo = "mxcl/master"
|
|
|
|
repo_path = "Library/Formula"
|
|
|
|
issues_url = ISSUES_URL
|
|
|
|
end
|
|
|
|
|
2012-03-06 18:08:16 +00:00
|
|
|
if ARGV.verbose?
|
|
|
|
ohai "Exit Status: #{e.exit_status}"
|
|
|
|
puts "https://github.com/#{repo}/blob/master/#{repo_path}/#{formula_name}.rb#L#{error_line}"
|
|
|
|
end
|
|
|
|
ohai "Build Environment"
|
|
|
|
Homebrew.dump_build_config
|
2012-03-07 11:11:05 +00:00
|
|
|
puts %["--use-clang" was specified] if ARGV.include? '--use-clang'
|
|
|
|
puts %["--use-llvm" was specified] if ARGV.include? '--use-llvm'
|
|
|
|
puts %["--use-gcc" was specified] if ARGV.include? '--use-gcc'
|
|
|
|
Homebrew.dump_build_env e.env
|
2012-03-06 18:08:16 +00:00
|
|
|
onoe "#{e.to_s.strip} (#{formula_name}.rb:#{error_line})"
|
2012-03-07 11:11:05 +00:00
|
|
|
issues = GitHub.issues_for_formula formula_name
|
|
|
|
if issues.empty?
|
|
|
|
puts "If `brew doctor' does not help diagnose the issue, please report the bug:"
|
2012-03-05 16:36:57 +00:00
|
|
|
puts " #{Tty.em}#{issues_url}#{Tty.reset}"
|
2012-03-07 11:11:05 +00:00
|
|
|
else
|
|
|
|
puts "These existing issues may help you:", *issues.map{ |s| " #{Tty.em}#{s}#{Tty.reset}" }
|
|
|
|
puts "Otherwise, please report the bug:"
|
2012-03-05 16:36:57 +00:00
|
|
|
puts " #{Tty.em}#{issues_url}#{Tty.reset}"
|
2012-03-07 11:11:05 +00:00
|
|
|
end
|
|
|
|
if e.was_running_configure?
|
|
|
|
puts "We saved the configure log, please gist it if you report the issue:"
|
|
|
|
puts " ~/Library/Logs/Homebrew/config.log"
|
|
|
|
end
|
|
|
|
end
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
2011-09-14 12:18:35 -07:00
|
|
|
|
2011-09-19 23:29:07 +01:00
|
|
|
# raised in CurlDownloadStrategy.fetch
|
|
|
|
class CurlDownloadStrategyError < RuntimeError
|
|
|
|
end
|
2011-09-14 12:18:35 -07:00
|
|
|
|
2011-09-19 23:29:07 +01:00
|
|
|
# raised by safe_system in utils.rb
|
|
|
|
class ErrorDuringExecution < RuntimeError
|
2011-09-14 12:18:35 -07:00
|
|
|
end
|