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
|
2014-12-23 15:36:44 -05:00
|
|
|
super "invalid attribute: #{attr} (#{value.inspect})"
|
2013-04-13 17:40:12 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-08-06 21:48:05 -07:00
|
|
|
class FormulaSpecificationError < StandardError; end
|
2013-04-27 14:44:48 -05:00
|
|
|
|
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
|
|
|
|
2014-02-28 15:58:20 -06:00
|
|
|
def initialize name
|
|
|
|
@name = name
|
|
|
|
end
|
|
|
|
|
2012-03-16 11:55:30 +00:00
|
|
|
def dependent_s
|
|
|
|
"(dependency of #{dependent})" if dependent and dependent != name
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
2014-02-28 15:58:20 -06:00
|
|
|
"No available formula for #{name} #{dependent_s}"
|
2012-03-16 11:55:30 +00:00
|
|
|
end
|
2014-02-28 15:58:20 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
class TapFormulaUnavailableError < FormulaUnavailableError
|
|
|
|
attr_reader :user, :repo, :shortname
|
2010-11-12 20:59:53 -08:00
|
|
|
|
2010-09-11 20:22:54 +01:00
|
|
|
def initialize name
|
2014-02-28 15:58:20 -06:00
|
|
|
super
|
|
|
|
@user, @repo, @shortname = name.split("/", 3)
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s; <<-EOS.undent
|
|
|
|
No available formula for #{shortname} #{dependent_s}
|
|
|
|
Please tap it and then try again: brew tap #{user}/#{repo}
|
|
|
|
EOS
|
2010-09-11 20:22:54 +01:00
|
|
|
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
|
|
|
|
|
2013-08-06 21:48:05 -07:00
|
|
|
class CannotInstallFormulaError < RuntimeError; end
|
2010-09-11 20:22:54 +01:00
|
|
|
|
2014-09-14 01:10:20 -05:00
|
|
|
class FormulaInstallationAlreadyAttemptedError < RuntimeError
|
2014-09-12 21:28:25 -05:00
|
|
|
def initialize(formula)
|
2014-09-14 11:18:55 -05:00
|
|
|
super "Formula installation already attempted: #{formula.name}"
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-14 01:10:20 -05:00
|
|
|
class UnsatisfiedRequirements < RuntimeError
|
|
|
|
def initialize(reqs)
|
|
|
|
if reqs.length == 1
|
|
|
|
super "An unsatisfied requirement failed this build."
|
|
|
|
else
|
|
|
|
super "Unsatisified requirements failed this build."
|
|
|
|
end
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-14 01:10:20 -05:00
|
|
|
class FormulaConflictError < RuntimeError
|
|
|
|
attr_reader :formula, :conflicts
|
2013-06-09 13:44:59 -05:00
|
|
|
|
2014-09-12 21:27:00 -05:00
|
|
|
def initialize(formula, conflicts)
|
|
|
|
@formula = formula
|
2014-09-14 01:10:20 -05:00
|
|
|
@conflicts = conflicts
|
|
|
|
super message
|
2013-06-09 13:44:59 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def conflict_message(conflict)
|
|
|
|
message = []
|
|
|
|
message << " #{conflict.name}"
|
|
|
|
message << ": because #{conflict.reason}" if conflict.reason
|
|
|
|
message.join
|
|
|
|
end
|
|
|
|
|
|
|
|
def message
|
|
|
|
message = []
|
2014-09-12 21:27:00 -05:00
|
|
|
message << "Cannot install #{formula.name} because conflicting formulae are installed.\n"
|
2013-06-09 13:44:59 -05:00
|
|
|
message.concat conflicts.map { |c| conflict_message(c) } << ""
|
|
|
|
message << <<-EOS.undent
|
|
|
|
Please `brew unlink #{conflicts.map(&:name)*' '}` before continuing.
|
|
|
|
|
|
|
|
Unlinking removes a formula's symlinks from #{HOMEBREW_PREFIX}. You can
|
|
|
|
link the formula again after the install finishes. You can --force this
|
|
|
|
install, but the build may fail or cause obscure side-effects in the
|
|
|
|
resulting software.
|
|
|
|
EOS
|
|
|
|
message.join("\n")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-14 01:10:20 -05:00
|
|
|
class BuildError < RuntimeError
|
|
|
|
attr_reader :formula, :env
|
2010-09-11 20:22:54 +01:00
|
|
|
|
2014-09-13 19:47:30 -05:00
|
|
|
def initialize(formula, cmd, args, env)
|
2014-09-14 01:10:20 -05:00
|
|
|
@formula = formula
|
2014-09-13 19:47:30 -05:00
|
|
|
@env = env
|
2011-03-14 15:48:35 -07:00
|
|
|
args = args.map{ |arg| arg.to_s.gsub " ", "\\ " }.join(" ")
|
2014-09-14 01:10:20 -05:00
|
|
|
super "Failed executing: #{cmd} #{args}"
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
2012-03-07 11:11:05 +00:00
|
|
|
|
2012-10-31 11:26:45 -04:00
|
|
|
def issues
|
2014-02-08 16:04:53 -05:00
|
|
|
@issues ||= fetch_issues
|
|
|
|
end
|
|
|
|
|
|
|
|
def fetch_issues
|
|
|
|
GitHub.issues_for_formula(formula.name)
|
|
|
|
rescue GitHub::RateLimitExceededError => e
|
|
|
|
opoo e.message
|
|
|
|
[]
|
2012-10-31 11:26:45 -04:00
|
|
|
end
|
|
|
|
|
2012-03-07 11:11:05 +00:00
|
|
|
def dump
|
2012-10-31 11:26:45 -04:00
|
|
|
if not ARGV.verbose?
|
|
|
|
puts
|
2014-07-12 09:00:40 -04:00
|
|
|
puts "#{Tty.red}READ THIS#{Tty.reset}: #{Tty.em}#{OS::ISSUES_URL}#{Tty.reset}"
|
2013-10-29 15:46:29 -04:00
|
|
|
if formula.tap?
|
2015-02-26 19:17:12 +00:00
|
|
|
case formula.tap
|
|
|
|
when "homebrew/homebrew-boneyard"
|
|
|
|
puts "#{formula} was moved to homebrew-boneyard because it has unfixable issues."
|
|
|
|
puts "Please do not file any issues about this. Sorry!"
|
|
|
|
else
|
|
|
|
puts "If reporting this issue please do so at (not Homebrew/homebrew):"
|
|
|
|
puts " https://github.com/#{formula.tap}/issues"
|
|
|
|
end
|
2013-10-29 15:46:29 -04:00
|
|
|
end
|
2012-10-31 11:26:45 -04:00
|
|
|
else
|
2014-04-26 23:31:39 -07:00
|
|
|
require 'cmd/config'
|
2012-09-27 15:39:16 -04:00
|
|
|
require 'cmd/--env'
|
2013-06-23 16:15:11 -07:00
|
|
|
|
|
|
|
unless formula.core_formula?
|
|
|
|
ohai "Formula"
|
2013-06-23 16:21:48 -07:00
|
|
|
puts "Tap: #{formula.tap}"
|
2014-04-06 00:31:07 -05:00
|
|
|
puts "Path: #{formula.path}"
|
2013-06-23 16:15:11 -07:00
|
|
|
end
|
2012-09-27 15:39:16 -04:00
|
|
|
ohai "Configuration"
|
2014-12-30 23:33:50 -05:00
|
|
|
Homebrew.dump_verbose_config
|
2012-09-27 15:39:16 -04:00
|
|
|
ohai "ENV"
|
|
|
|
Homebrew.dump_build_env(env)
|
2012-10-31 11:26:45 -04:00
|
|
|
puts
|
2014-04-06 12:00:17 -07:00
|
|
|
onoe "#{formula.name} #{formula.version} did not build"
|
2014-09-14 11:18:55 -05:00
|
|
|
unless (logs = Dir["#{HOMEBREW_LOGS}/#{formula.name}/*"]).empty?
|
2013-10-27 17:17:09 +01:00
|
|
|
puts "Logs:"
|
|
|
|
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
|
2014-03-17 11:52:11 -07:00
|
|
|
unless RUBY_VERSION < "1.8.7" || issues.empty?
|
2012-10-31 11:26:45 -04:00
|
|
|
puts "These open issues may also help:"
|
2014-01-20 17:46:33 -08:00
|
|
|
puts issues.map{ |i| "#{i['title']} (#{i['html_url']})" }.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
|
2014-09-14 01:10:20 -05:00
|
|
|
class CompilerSelectionError < RuntimeError
|
|
|
|
def initialize(formula)
|
|
|
|
super <<-EOS.undent
|
|
|
|
#{formula.name} cannot be built with any available compilers.
|
|
|
|
To install this formula, you may need to:
|
|
|
|
brew install gcc
|
|
|
|
EOS
|
2013-05-20 19:35:07 -05:00
|
|
|
end
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
2011-09-14 12:18:35 -07:00
|
|
|
|
2014-02-18 15:08:03 -05:00
|
|
|
# Raised in Resource.fetch
|
|
|
|
class DownloadError < RuntimeError
|
2014-12-29 22:51:55 -05:00
|
|
|
def initialize(resource, cause)
|
2014-02-18 15:08:03 -05:00
|
|
|
super <<-EOS.undent
|
|
|
|
Failed to download resource #{resource.download_name.inspect}
|
2014-12-29 22:51:55 -05:00
|
|
|
#{cause.message}
|
2014-02-18 15:08:03 -05:00
|
|
|
EOS
|
2014-12-29 22:51:55 -05:00
|
|
|
set_backtrace(cause.backtrace)
|
2014-02-18 15:08:03 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-09-19 23:29:07 +01:00
|
|
|
# raised in CurlDownloadStrategy.fetch
|
2014-12-29 22:52:53 -05:00
|
|
|
class CurlDownloadStrategyError < RuntimeError
|
|
|
|
def initialize(url)
|
|
|
|
case url
|
|
|
|
when %r[^file://(.+)]
|
|
|
|
super "File does not exist: #{$1}"
|
|
|
|
else
|
|
|
|
super "Download failed: #{url}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-09-14 12:18:35 -07:00
|
|
|
|
2011-09-19 23:29:07 +01:00
|
|
|
# raised by safe_system in utils.rb
|
2014-09-18 20:32:50 -05:00
|
|
|
class ErrorDuringExecution < RuntimeError
|
|
|
|
def initialize(cmd, args=[])
|
|
|
|
args = args.map { |a| a.to_s.gsub " ", "\\ " }.join(" ")
|
|
|
|
super "Failure while executing: #{cmd} #{args}"
|
|
|
|
end
|
|
|
|
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
|
2013-08-06 21:48:05 -07:00
|
|
|
class ChecksumMissingError < ArgumentError; end
|
2012-06-18 19:58:35 -05:00
|
|
|
|
|
|
|
# raised by Pathname#verify_checksum when verification fails
|
|
|
|
class ChecksumMismatchError < RuntimeError
|
2014-02-18 13:27:35 -05:00
|
|
|
attr_reader :expected, :hash_type
|
2012-06-18 19:58:35 -05:00
|
|
|
|
2014-02-18 13:27:35 -05:00
|
|
|
def initialize fn, expected, actual
|
2012-06-18 19:58:35 -05:00
|
|
|
@expected = expected
|
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
|
2014-02-18 13:27:35 -05:00
|
|
|
Expected: #{expected}
|
|
|
|
Actual: #{actual}
|
|
|
|
Archive: #{fn}
|
|
|
|
To retry an incomplete download, remove the file above.
|
2012-06-18 19:58:35 -05:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
2013-08-06 19:52:58 -07:00
|
|
|
|
|
|
|
class ResourceMissingError < ArgumentError
|
2014-09-12 21:19:25 -05:00
|
|
|
def initialize(formula, resource)
|
2014-09-14 11:18:55 -05:00
|
|
|
super "#{formula.name} does not define resource #{resource.inspect}"
|
2013-08-06 19:52:58 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class DuplicateResourceError < ArgumentError
|
2014-09-12 21:19:25 -05:00
|
|
|
def initialize(resource)
|
|
|
|
super "Resource #{resource.inspect} is defined more than once"
|
2013-08-06 19:52:58 -07:00
|
|
|
end
|
|
|
|
end
|