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
|
2013-02-17 22:52:39 -06:00
|
|
|
attr_reader :name
|
2010-11-12 20:59:53 -08:00
|
|
|
|
|
|
|
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
|
2013-02-17 22:52:39 -06:00
|
|
|
attr_reader :name
|
2010-11-12 20:59:53 -08:00
|
|
|
|
|
|
|
def initialize name
|
|
|
|
@name = name
|
|
|
|
super "No such keg: #{HOMEBREW_CELLAR}/#{name}"
|
|
|
|
end
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
|
|
|
|
2013-04-13 17:40:12 -05:00
|
|
|
class FormulaValidationError < StandardError
|
|
|
|
attr_reader :attr
|
|
|
|
|
|
|
|
def initialize(attr, value)
|
|
|
|
@attr = attr
|
|
|
|
msg = "invalid attribute: #{attr}"
|
|
|
|
msg << " (#{value.inspect})" unless value.empty?
|
|
|
|
super msg
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-04-27 14:44:48 -05:00
|
|
|
class FormulaSpecificationError < StandardError
|
|
|
|
end
|
|
|
|
|
2010-09-11 20:22:54 +01:00
|
|
|
class FormulaUnavailableError < RuntimeError
|
2013-02-17 22:52:39 -06:00
|
|
|
attr_reader :name
|
|
|
|
attr_accessor :dependent
|
2012-03-16 11:55:30 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2013-01-23 00:26:25 -06:00
|
|
|
class OperationInProgressError < RuntimeError
|
|
|
|
def initialize name
|
|
|
|
message = <<-EOS.undent
|
|
|
|
Operation already in progress for #{name}
|
|
|
|
Another active Homebrew process is already using #{name}.
|
|
|
|
Please wait for it to finish or terminate it to continue.
|
|
|
|
EOS
|
|
|
|
|
|
|
|
super message
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-09-11 20:22:54 +01:00
|
|
|
module Homebrew
|
|
|
|
class InstallationError < RuntimeError
|
2013-02-17 22:52:39 -06:00
|
|
|
attr_reader :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
|
|
|
|
|
2013-04-03 18:26:40 -05:00
|
|
|
class FormulaAlreadyInstalledError < RuntimeError
|
|
|
|
end
|
|
|
|
|
2010-09-11 20:22:54 +01:00
|
|
|
class FormulaInstallationAlreadyAttemptedError < Homebrew::InstallationError
|
|
|
|
def message
|
|
|
|
"Formula installation already attempted: #{formula}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-27 19:40:10 -06:00
|
|
|
class UnsatisfiedDependencyError < Homebrew::InstallationError
|
|
|
|
def initialize(f, dep)
|
|
|
|
super f, <<-EOS.undent
|
|
|
|
#{f} dependency #{dep} not installed with:
|
|
|
|
#{dep.missing_options * ', '}
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-23 17:06:38 -07:00
|
|
|
class UnsatisfiedRequirements < Homebrew::InstallationError
|
2013-02-17 22:52:39 -06:00
|
|
|
attr_reader :reqs
|
2012-07-23 17:06:38 -07:00
|
|
|
|
|
|
|
def initialize formula, reqs
|
|
|
|
@reqs = reqs
|
|
|
|
message = (reqs.length == 1) \
|
|
|
|
? "An unsatisfied requirement failed this build." \
|
|
|
|
: "Unsatisifed requirements failed this build."
|
|
|
|
super formula, message
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class BuildError < Homebrew::InstallationError
|
2013-02-17 22:52:39 -06:00
|
|
|
attr_reader :exit_status, :command, :env
|
2010-09-11 20:22:54 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
2012-10-31 11:26:45 -04:00
|
|
|
def issues
|
|
|
|
@issues ||= GitHub.issues_for_formula(formula.name)
|
|
|
|
end
|
|
|
|
|
2012-03-07 11:11:05 +00:00
|
|
|
def dump
|
2012-10-31 11:26:45 -04:00
|
|
|
if not ARGV.verbose?
|
|
|
|
puts
|
|
|
|
puts "#{Tty.red}READ THIS#{Tty.reset}: #{Tty.em}#{ISSUES_URL}#{Tty.reset}"
|
|
|
|
else
|
2012-09-27 15:39:16 -04:00
|
|
|
require 'cmd/--config'
|
|
|
|
require 'cmd/--env'
|
|
|
|
ohai "Configuration"
|
|
|
|
Homebrew.dump_build_config
|
|
|
|
ohai "ENV"
|
|
|
|
Homebrew.dump_build_env(env)
|
2012-10-31 11:26:45 -04:00
|
|
|
puts
|
|
|
|
onoe "#{formula.name} did not build"
|
|
|
|
unless (logs = Dir["#{ENV['HOME']}/Library/Logs/Homebrew/#{formula}/*"]).empty?
|
|
|
|
print "Logs: "
|
2013-02-17 22:48:38 -06:00
|
|
|
puts logs.map{|fn| " #{fn}"}.join("\n")
|
2012-10-31 11:26:45 -04:00
|
|
|
end
|
2012-09-27 15:39:16 -04:00
|
|
|
end
|
2012-08-13 09:50:15 -04:00
|
|
|
puts
|
2013-06-02 18:33:29 -05:00
|
|
|
unless RUBY_VERSION < "1.8.6" || issues.empty?
|
2012-10-31 11:26:45 -04:00
|
|
|
puts "These open issues may also help:"
|
2013-02-17 22:48:38 -06:00
|
|
|
puts issues.map{ |s| " #{s}" }.join("\n")
|
2012-10-31 11:26:45 -04:00
|
|
|
end
|
2012-03-07 11:11:05 +00:00
|
|
|
end
|
2013-05-20 19:35:07 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
# raised by CompilerSelector if the formula fails with all of
|
|
|
|
# the compilers available on the user's system
|
|
|
|
class CompilerSelectionError < StandardError
|
|
|
|
def message
|
|
|
|
if MacOS.version > :tiger then <<-EOS.undent
|
|
|
|
This formula cannot be built with any available compilers.
|
|
|
|
To install this formula, you may need to:
|
|
|
|
brew tap homebrew/dupes
|
|
|
|
brew install apple-gcc42
|
|
|
|
EOS
|
|
|
|
# tigerbrew has a separate apple-gcc42 for Xcode 2.5
|
|
|
|
else <<-EOS.undent
|
|
|
|
This formula cannot be built with any available compilers.
|
|
|
|
To install this formula, you need to:
|
|
|
|
brew install apple-gcc42
|
|
|
|
EOS
|
|
|
|
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
|
2012-06-18 19:58:35 -05:00
|
|
|
|
2012-07-17 11:31:53 -05:00
|
|
|
# raised by Pathname#verify_checksum when "expected" is nil or empty
|
2012-06-18 19:58:35 -05:00
|
|
|
class ChecksumMissingError < ArgumentError
|
|
|
|
end
|
|
|
|
|
|
|
|
# raised by Pathname#verify_checksum when verification fails
|
|
|
|
class ChecksumMismatchError < RuntimeError
|
2013-02-17 22:52:39 -06:00
|
|
|
attr_accessor :advice
|
|
|
|
attr_reader :expected, :actual, :hash_type
|
2012-06-18 19:58:35 -05:00
|
|
|
|
|
|
|
def initialize expected, actual
|
|
|
|
@expected = expected
|
|
|
|
@actual = actual
|
2012-06-26 00:51:02 -05:00
|
|
|
@hash_type = expected.hash_type.to_s.upcase
|
2012-06-18 19:58:35 -05:00
|
|
|
|
|
|
|
super <<-EOS.undent
|
2012-06-26 00:51:02 -05:00
|
|
|
#{@hash_type} mismatch
|
|
|
|
Expected: #{@expected}
|
|
|
|
Actual: #{@actual}
|
2012-06-18 19:58:35 -05:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
2012-07-17 11:30:28 -05:00
|
|
|
super + advice.to_s
|
2012-06-18 19:58:35 -05:00
|
|
|
end
|
|
|
|
end
|