| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def initialize(name) | 
					
						
							| 
									
										
										
										
											2010-11-12 20:59:53 -08:00
										 |  |  |     @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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def initialize(name) | 
					
						
							| 
									
										
										
										
											2010-11-12 20:59:53 -08:00
										 |  |  |     @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 | 
					
						
							| 
									
										
										
										
											2015-10-14 14:42:34 +02:00
										 |  |  |   attr_reader :attr, :formula | 
					
						
							| 
									
										
										
										
											2013-04-13 17:40:12 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-14 14:42:34 +02:00
										 |  |  |   def initialize(formula, attr, value) | 
					
						
							| 
									
										
										
										
											2013-04-13 17:40:12 -05:00
										 |  |  |     @attr = attr | 
					
						
							| 
									
										
										
										
											2015-10-14 14:42:34 +02:00
										 |  |  |     @formula = formula | 
					
						
							|  |  |  |     super "invalid attribute for formula '#{formula}': #{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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def initialize(name) | 
					
						
							| 
									
										
										
										
											2014-02-28 15:58:20 -06:00
										 |  |  |     @name = name | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-16 11:55:30 +00:00
										 |  |  |   def dependent_s | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     "(dependency of #{dependent})" if dependent && dependent != name | 
					
						
							| 
									
										
										
										
											2012-03-16 11:55:30 +00:00
										 |  |  |   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 | 
					
						
							| 
									
										
										
										
											2015-07-19 16:42:40 +08:00
										 |  |  |   attr_reader :tap, :user, :repo | 
					
						
							| 
									
										
										
										
											2010-11-12 20:59:53 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def initialize(tap, name) | 
					
						
							| 
									
										
										
										
											2015-07-14 21:33:29 +08:00
										 |  |  |     @tap = tap | 
					
						
							| 
									
										
										
										
											2015-07-19 16:42:40 +08:00
										 |  |  |     @user = tap.user | 
					
						
							|  |  |  |     @repo = tap.repo | 
					
						
							| 
									
										
										
										
											2015-07-14 21:33:29 +08:00
										 |  |  |     super "#{tap}/#{name}" | 
					
						
							| 
									
										
										
										
											2014-02-28 15:58:20 -06:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-14 21:33:29 +08:00
										 |  |  |   def to_s | 
					
						
							|  |  |  |     s = super | 
					
						
							|  |  |  |     s += "\nPlease tap it and then try again: brew tap #{tap}" unless tap.installed? | 
					
						
							|  |  |  |     s | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-08 19:16:06 +08:00
										 |  |  | class TapFormulaAmbiguityError < RuntimeError | 
					
						
							|  |  |  |   attr_reader :name, :paths, :formulae | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def initialize(name, paths) | 
					
						
							| 
									
										
										
										
											2015-05-08 19:16:06 +08:00
										 |  |  |     @name = name | 
					
						
							|  |  |  |     @paths = paths | 
					
						
							|  |  |  |     @formulae = paths.map do |path| | 
					
						
							|  |  |  |       path.to_s =~ HOMEBREW_TAP_PATH_REGEX | 
					
						
							|  |  |  |       "#{$1}/#{$2.sub("homebrew-", "")}/#{path.basename(".rb")}" | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     super <<-EOS.undent
 | 
					
						
							|  |  |  |       Formulae found in multiple taps: #{formulae.map { |f| "\n       * #{f}" }.join} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       Please use the fully-qualified name e.g. #{formulae.first} to refer the formula. | 
					
						
							|  |  |  |     EOS | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-09 15:08:12 +03:00
										 |  |  | class TapFormulaWithOldnameAmbiguityError < RuntimeError | 
					
						
							|  |  |  |   attr_reader :name, :possible_tap_newname_formulae, :taps | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def initialize(name, possible_tap_newname_formulae) | 
					
						
							|  |  |  |     @name = name | 
					
						
							|  |  |  |     @possible_tap_newname_formulae = possible_tap_newname_formulae | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @taps = possible_tap_newname_formulae.map do |newname| | 
					
						
							|  |  |  |       newname =~ HOMEBREW_TAP_FORMULA_REGEX | 
					
						
							|  |  |  |       "#{$1}/#{$2}" | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     super <<-EOS.undent
 | 
					
						
							| 
									
										
										
										
											2015-08-22 13:15:33 +08:00
										 |  |  |       Formulae with '#{name}' old name found in multiple taps: #{taps.map { |t| "\n       * #{t}" }.join} | 
					
						
							| 
									
										
										
										
											2015-08-09 15:08:12 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |       Please use the fully-qualified name e.g. #{taps.first}/#{name} to refer the formula or use its new name. | 
					
						
							|  |  |  |     EOS | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-13 14:32:10 +08:00
										 |  |  | class TapUnavailableError < RuntimeError | 
					
						
							|  |  |  |   attr_reader :name | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def initialize(name) | 
					
						
							| 
									
										
										
										
											2015-06-13 14:32:10 +08:00
										 |  |  |     @name = name | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     super <<-EOS.undent
 | 
					
						
							|  |  |  |       No available tap #{name}. | 
					
						
							|  |  |  |     EOS | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-09 22:42:46 +08:00
										 |  |  | class TapPinStatusError < RuntimeError | 
					
						
							|  |  |  |   attr_reader :name, :pinned | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-22 13:15:33 +08:00
										 |  |  |   def initialize(name, pinned) | 
					
						
							| 
									
										
										
										
											2015-08-09 22:42:46 +08:00
										 |  |  |     @name = name | 
					
						
							|  |  |  |     @pinned = pinned | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     super pinned ? "#{name} is already pinned." : "#{name} is already unpinned." | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-23 00:26:25 -06:00
										 |  |  | class OperationInProgressError < RuntimeError | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def initialize(name) | 
					
						
							| 
									
										
										
										
											2013-01-23 00:26:25 -06:00
										 |  |  |     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) | 
					
						
							| 
									
										
										
										
											2015-05-27 22:16:48 +08:00
										 |  |  |     super "Formula installation already attempted: #{formula.full_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 | 
					
						
							| 
									
										
										
										
											2015-07-26 00:48:50 -04:00
										 |  |  |       super "Unsatisfied requirements failed this build." | 
					
						
							| 
									
										
										
										
											2014-09-14 01:10:20 -05:00
										 |  |  |     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 = [] | 
					
						
							| 
									
										
										
										
											2015-05-27 22:16:48 +08:00
										 |  |  |     message << "Cannot install #{formula.full_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
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |       Please `brew unlink #{conflicts.map(&:name)*" "}` before continuing. | 
					
						
							| 
									
										
										
										
											2013-06-09 13:44:59 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |       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 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01: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 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     if !ARGV.verbose? | 
					
						
							| 
									
										
										
										
											2012-10-31 11:26:45 -04:00
										 |  |  |       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 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |       require "cmd/config" | 
					
						
							|  |  |  |       require "cmd/--env" | 
					
						
							| 
									
										
										
										
											2013-06-23 16:15:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-03 21:11:00 -05:00
										 |  |  |       ohai "Formula" | 
					
						
							|  |  |  |       puts "Tap: #{formula.tap}" if formula.tap? | 
					
						
							|  |  |  |       puts "Path: #{formula.path}" | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											2015-05-27 22:16:48 +08:00
										 |  |  |       onoe "#{formula.full_name} #{formula.version} did not build" | 
					
						
							| 
									
										
										
										
											2015-04-25 22:07:06 -04:00
										 |  |  |       unless (logs = Dir["#{formula.logs}/*"]).empty? | 
					
						
							| 
									
										
										
										
											2013-10-27 17:17:09 +01:00
										 |  |  |         puts "Logs:" | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01: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 | 
					
						
							| 
									
										
										
										
											2015-09-06 13:30:02 +01:00
										 |  |  |     if RUBY_VERSION >= "1.8.7" && issues && issues.any? | 
					
						
							| 
									
										
										
										
											2012-10-31 11:26:45 -04:00
										 |  |  |       puts "These open issues may also help:" | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |       puts issues.map { |i| "#{i["title"]} #{i["html_url"]}" }.join("\n") | 
					
						
							| 
									
										
										
										
											2012-10-31 11:26:45 -04:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2015-06-16 20:02:10 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if MacOS.version >= "10.11" | 
					
						
							|  |  |  |       require "cmd/doctor" | 
					
						
							|  |  |  |       opoo Checks.new.check_for_unsupported_osx | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2012-03-07 11:11:05 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2013-05-20 19:35:07 -05:00
										 |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-29 14:09:57 -04:00
										 |  |  | # raised by FormulaInstaller.check_dependencies_bottled and | 
					
						
							|  |  |  | # FormulaInstaller.install if the formula or its dependencies are not bottled | 
					
						
							|  |  |  | # and are being installed on a system without necessary build tools | 
					
						
							|  |  |  | class BuildToolsError < RuntimeError | 
					
						
							|  |  |  |   def initialize(formulae) | 
					
						
							|  |  |  |     if formulae.length > 1
 | 
					
						
							|  |  |  |       formula_text = "formulae" | 
					
						
							|  |  |  |       package_text = "binary packages" | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |       formula_text = "formula" | 
					
						
							|  |  |  |       package_text = "a binary package" | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if MacOS.version >= "10.10" | 
					
						
							|  |  |  |       xcode_text = <<-EOS.undent
 | 
					
						
							|  |  |  |         To continue, you must install Xcode from the App Store, | 
					
						
							| 
									
										
										
										
											2015-08-26 17:04:02 -04:00
										 |  |  |         or the CLT by running: | 
					
						
							|  |  |  |           xcode-select --install | 
					
						
							| 
									
										
										
										
											2015-06-29 14:09:57 -04:00
										 |  |  |       EOS | 
					
						
							|  |  |  |     elsif MacOS.version == "10.9" | 
					
						
							|  |  |  |       xcode_text = <<-EOS.undent
 | 
					
						
							|  |  |  |         To continue, you must install Xcode from: | 
					
						
							| 
									
										
										
										
											2015-08-26 17:04:02 -04:00
										 |  |  |           https://developer.apple.com/downloads/ | 
					
						
							|  |  |  |         or the CLT by running: | 
					
						
							|  |  |  |           xcode-select --install | 
					
						
							| 
									
										
										
										
											2015-06-29 14:09:57 -04:00
										 |  |  |       EOS | 
					
						
							|  |  |  |     elsif MacOS.version >= "10.7" | 
					
						
							|  |  |  |       xcode_text = <<-EOS.undent
 | 
					
						
							|  |  |  |         To continue, you must install Xcode or the CLT from: | 
					
						
							| 
									
										
										
										
											2015-08-26 17:04:02 -04:00
										 |  |  |           https://developer.apple.com/downloads/ | 
					
						
							| 
									
										
										
										
											2015-06-29 14:09:57 -04:00
										 |  |  |       EOS | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |       xcode_text = <<-EOS.undent
 | 
					
						
							|  |  |  |         To continue, you must install Xcode from: | 
					
						
							| 
									
										
										
										
											2015-08-26 17:04:02 -04:00
										 |  |  |           https://developer.apple.com/xcode/downloads/ | 
					
						
							| 
									
										
										
										
											2015-06-29 14:09:57 -04:00
										 |  |  |       EOS | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     super <<-EOS.undent
 | 
					
						
							|  |  |  |       The following #{formula_text}: | 
					
						
							| 
									
										
										
										
											2015-08-22 13:15:33 +08:00
										 |  |  |         #{formulae.join(", ")} | 
					
						
							| 
									
										
										
										
											2015-06-29 14:09:57 -04:00
										 |  |  |       cannot be installed as a #{package_text} and must be built from source. | 
					
						
							|  |  |  |       #{xcode_text} | 
					
						
							|  |  |  |     EOS | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # raised by Homebrew.install, Homebrew.reinstall, and Homebrew.upgrade | 
					
						
							|  |  |  | # if the user passes any flags/environment that would case a bottle-only | 
					
						
							|  |  |  | # installation on a system without build tools to fail | 
					
						
							|  |  |  | class BuildFlagsError < RuntimeError | 
					
						
							|  |  |  |   def initialize(flags) | 
					
						
							|  |  |  |     if flags.length > 1
 | 
					
						
							|  |  |  |       flag_text = "flags" | 
					
						
							|  |  |  |       require_text = "require" | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |       flag_text = "flag" | 
					
						
							|  |  |  |       require_text = "requires" | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if MacOS.version >= "10.10" | 
					
						
							|  |  |  |       xcode_text = <<-EOS.undent
 | 
					
						
							|  |  |  |         or install Xcode from the App Store, or the CLT by running: | 
					
						
							| 
									
										
										
										
											2015-08-26 17:04:02 -04:00
										 |  |  |           xcode-select --install | 
					
						
							| 
									
										
										
										
											2015-06-29 14:09:57 -04:00
										 |  |  |       EOS | 
					
						
							|  |  |  |     elsif MacOS.version == "10.9" | 
					
						
							|  |  |  |       xcode_text = <<-EOS.undent
 | 
					
						
							|  |  |  |         or install Xcode from: | 
					
						
							| 
									
										
										
										
											2015-08-26 17:04:02 -04:00
										 |  |  |           https://developer.apple.com/downloads/ | 
					
						
							|  |  |  |         or the CLT by running: | 
					
						
							|  |  |  |           xcode-select --install | 
					
						
							| 
									
										
										
										
											2015-06-29 14:09:57 -04:00
										 |  |  |       EOS | 
					
						
							|  |  |  |     elsif MacOS.version >= "10.7" | 
					
						
							|  |  |  |       xcode_text = <<-EOS.undent
 | 
					
						
							|  |  |  |         or install Xcode or the CLT from: | 
					
						
							| 
									
										
										
										
											2015-08-26 17:04:02 -04:00
										 |  |  |           https://developer.apple.com/downloads/ | 
					
						
							| 
									
										
										
										
											2015-06-29 14:09:57 -04:00
										 |  |  |       EOS | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |       xcode_text = <<-EOS.undent
 | 
					
						
							|  |  |  |         or install Xcode from: | 
					
						
							| 
									
										
										
										
											2015-08-26 17:04:02 -04:00
										 |  |  |           https://developer.apple.com/xcode/downloads/ | 
					
						
							| 
									
										
										
										
											2015-06-29 14:09:57 -04:00
										 |  |  |       EOS | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     super <<-EOS.undent
 | 
					
						
							|  |  |  |       The following #{flag_text}: | 
					
						
							| 
									
										
										
										
											2015-08-22 13:15:33 +08:00
										 |  |  |         #{flags.join(", ")} | 
					
						
							| 
									
										
										
										
											2015-06-29 14:09:57 -04:00
										 |  |  |       #{require_text} building tools, but none are installed. | 
					
						
							|  |  |  |       Either remove the #{flag_text} to attempt bottle installation, | 
					
						
							|  |  |  |       #{xcode_text} | 
					
						
							|  |  |  |     EOS | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-20 19:35:07 -05:00
										 |  |  | # 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
 | 
					
						
							| 
									
										
										
										
											2015-05-27 22:16:48 +08:00
										 |  |  |       #{formula.full_name} cannot be built with any available compilers. | 
					
						
							| 
									
										
										
										
											2014-09-14 01:10:20 -05:00
										 |  |  |       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 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     when %r{^file://(.+)} | 
					
						
							| 
									
										
										
										
											2014-12-29 22:52:53 -05:00
										 |  |  |       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 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def initialize(cmd, args = []) | 
					
						
							| 
									
										
										
										
											2014-09-18 20:32:50 -05:00
										 |  |  |     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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01: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) | 
					
						
							| 
									
										
										
										
											2015-05-27 22:16:48 +08:00
										 |  |  |     super "#{formula.full_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 | 
					
						
							| 
									
										
										
										
											2015-07-23 14:09:32 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | class BottleVersionMismatchError < RuntimeError | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def initialize(bottle_file, bottle_version, formula, formula_version) | 
					
						
							| 
									
										
										
										
											2015-07-23 14:09:32 +08:00
										 |  |  |     super <<-EOS.undent
 | 
					
						
							|  |  |  |       Bottle version mismatch | 
					
						
							|  |  |  |       Bottle: #{bottle_file} (#{bottle_version}) | 
					
						
							|  |  |  |       Formula: #{formula.full_name} (#{formula_version}) | 
					
						
							|  |  |  |     EOS | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |