| 
									
										
										
										
											2024-06-02 15:14:25 +01:00
										 |  |  | # typed: strict | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-18 13:55:19 -07:00
										 |  |  | # `HOMEBREW_STACKPROF` should be set via `brew prof --stackprof`, not manually. | 
					
						
							| 
									
										
										
										
											2020-08-20 13:01:58 +01:00
										 |  |  | if ENV["HOMEBREW_STACKPROF"] | 
					
						
							| 
									
										
										
										
											2022-12-29 17:44:48 -08:00
										 |  |  |   require "rubygems" | 
					
						
							| 
									
										
										
										
											2020-08-20 13:01:58 +01:00
										 |  |  |   require "stackprof" | 
					
						
							|  |  |  |   StackProf.start(mode: :wall, raw: true) | 
					
						
							|  |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-19 13:11:32 +00:00
										 |  |  | raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" unless ENV["HOMEBREW_BREW_FILE"] | 
					
						
							| 
									
										
										
										
											2022-12-04 20:07:31 -08:00
										 |  |  | if $PROGRAM_NAME != __FILE__ && !$PROGRAM_NAME.end_with?("/bin/ruby-prof") | 
					
						
							|  |  |  |   raise "#{__FILE__} must not be loaded via `require`." | 
					
						
							|  |  |  | end | 
					
						
							| 
									
										
										
										
											2016-08-24 14:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-22 15:50:27 -04:00
										 |  |  | std_trap = trap("INT") { exit! 130 } # no backtrace thanks | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-30 04:05:07 +01:00
										 |  |  | require_relative "global" | 
					
						
							| 
									
										
										
										
											2009-08-10 16:48:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-02 13:39:39 +01:00
										 |  |  | begin | 
					
						
							| 
									
										
										
										
											2012-08-22 15:50:27 -04:00
										 |  |  |   trap("INT", std_trap) # restore default CTRL-C handler | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-11 22:15:18 +01:00
										 |  |  |   if ENV["CI"] | 
					
						
							|  |  |  |     $stdout.sync = true | 
					
						
							|  |  |  |     $stderr.sync = true | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-25 09:45:01 +01:00
										 |  |  |   empty_argv = ARGV.empty? | 
					
						
							| 
									
										
										
										
											2016-04-17 04:07:36 +02:00
										 |  |  |   help_flag_list = %w[-h --help --usage -?] | 
					
						
							| 
									
										
										
										
											2016-10-01 18:17:52 +03:00
										 |  |  |   help_flag = !ENV["HOMEBREW_HELP"].nil? | 
					
						
							| 
									
										
										
										
											2023-03-18 13:55:19 -07:00
										 |  |  |   help_cmd_index = T.let(nil, T.nilable(Integer)) | 
					
						
							|  |  |  |   cmd = T.let(nil, T.nilable(String)) | 
					
						
							| 
									
										
										
										
											2014-06-25 09:45:01 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-23 19:39:11 +01:00
										 |  |  |   ARGV.each_with_index do |arg, i| | 
					
						
							| 
									
										
										
										
											2016-09-22 20:12:28 +02:00
										 |  |  |     break if help_flag && cmd | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-01 18:17:52 +03:00
										 |  |  |     if arg == "help" && !cmd | 
					
						
							| 
									
										
										
										
											2016-04-17 04:07:36 +02:00
										 |  |  |       # Command-style help: `help <cmd>` is fine, but `<cmd> help` is not. | 
					
						
							| 
									
										
										
										
											2014-06-25 09:45:01 +01:00
										 |  |  |       help_flag = true | 
					
						
							| 
									
										
										
										
											2020-07-31 17:37:36 +02:00
										 |  |  |       help_cmd_index = i | 
					
						
							| 
									
										
										
										
											2020-12-01 17:04:59 +00:00
										 |  |  |     elsif !cmd && help_flag_list.exclude?(arg) | 
					
						
							| 
									
										
										
										
											2024-07-14 08:49:39 -04:00
										 |  |  |       require "commands" | 
					
						
							| 
									
										
										
										
											2014-06-25 09:45:01 +01:00
										 |  |  |       cmd = ARGV.delete_at(i) | 
					
						
							| 
									
										
										
										
											2020-06-22 10:23:00 +05:30
										 |  |  |       cmd = Commands::HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd) | 
					
						
							| 
									
										
										
										
											2014-06-25 09:45:01 +01:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-31 17:37:36 +02:00
										 |  |  |   ARGV.delete_at(help_cmd_index) if help_cmd_index | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-25 09:18:10 +00:00
										 |  |  |   require "cli/parser" | 
					
						
							| 
									
										
										
										
											2024-08-10 09:22:12 -07:00
										 |  |  |   args = Homebrew::CLI::Parser.new(Homebrew::Cmd::Brew).parse(ARGV.dup.freeze, ignore_invalid_options: true) | 
					
						
							| 
									
										
										
										
											2020-08-02 14:32:31 +02:00
										 |  |  |   Context.current = args.context | 
					
						
							| 
									
										
										
										
											2020-07-30 18:40:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-15 05:40:43 +01:00
										 |  |  |   path = PATH.new(ENV.fetch("PATH")) | 
					
						
							|  |  |  |   homebrew_path = PATH.new(ENV.fetch("HOMEBREW_PATH")) | 
					
						
							| 
									
										
										
										
											2017-04-27 10:44:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-03 21:47:17 +01:00
										 |  |  |   # Add shared wrappers. | 
					
						
							|  |  |  |   path.prepend(HOMEBREW_SHIMS_PATH/"shared") | 
					
						
							|  |  |  |   homebrew_path.prepend(HOMEBREW_SHIMS_PATH/"shared") | 
					
						
							| 
									
										
										
										
											2017-04-27 10:44:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-18 13:55:19 -07:00
										 |  |  |   ENV["PATH"] = path.to_s | 
					
						
							| 
									
										
										
										
											2014-09-24 21:35:07 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-02 17:05:45 +01:00
										 |  |  |   require "commands" | 
					
						
							| 
									
										
										
										
											2015-09-10 21:20:34 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-26 01:29:15 -04:00
										 |  |  |   internal_cmd = Commands.valid_internal_cmd?(cmd) || Commands.valid_internal_dev_cmd?(cmd) if cmd | 
					
						
							| 
									
										
										
										
											2021-10-22 11:46:54 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-18 17:04:54 -08:00
										 |  |  |   unless internal_cmd | 
					
						
							|  |  |  |     # Add contributed commands to PATH before checking. | 
					
						
							| 
									
										
										
										
											2024-08-10 17:38:27 -07:00
										 |  |  |     homebrew_path.append(Commands.tap_cmd_directories) | 
					
						
							| 
									
										
										
										
											2017-11-18 17:04:54 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # External commands expect a normal PATH | 
					
						
							| 
									
										
										
										
											2023-03-18 13:55:19 -07:00
										 |  |  |     ENV["PATH"] = homebrew_path.to_s | 
					
						
							| 
									
										
										
										
											2017-11-18 17:04:54 -08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-25 09:45:01 +01:00
										 |  |  |   # Usage instructions should be displayed if and only if one of: | 
					
						
							| 
									
										
										
										
											2016-10-01 18:25:16 +01:00
										 |  |  |   # - a help flag is passed AND a command is matched | 
					
						
							| 
									
										
										
										
											2014-06-26 09:27:22 +01:00
										 |  |  |   # - a help flag is passed AND there is no command specified | 
					
						
							| 
									
										
										
										
											2014-06-25 09:45:01 +01:00
										 |  |  |   # - no arguments are passed | 
					
						
							| 
									
										
										
										
											2021-01-25 09:18:10 +00:00
										 |  |  |   if empty_argv || help_flag | 
					
						
							| 
									
										
										
										
											2018-06-05 23:19:18 -04:00
										 |  |  |     require "help" | 
					
						
							| 
									
										
										
										
											2024-03-07 16:20:20 +00:00
										 |  |  |     Homebrew::Help.help cmd, remaining_args: args.remaining, empty_argv: | 
					
						
							| 
									
										
										
										
											2020-08-02 15:36:05 +02:00
										 |  |  |     # `Homebrew::Help.help` never returns, except for unknown commands. | 
					
						
							| 
									
										
										
										
											2014-06-25 09:45:01 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-02 17:05:45 +01:00
										 |  |  |   if internal_cmd || Commands.external_ruby_v2_cmd_path(cmd) | 
					
						
							| 
									
										
										
										
											2024-11-04 08:51:05 +00:00
										 |  |  |     cmd = T.must(cmd) | 
					
						
							| 
									
										
										
										
											2024-04-25 17:38:04 +01:00
										 |  |  |     cmd_class = Homebrew::AbstractCommand.command(cmd) | 
					
						
							| 
									
										
										
										
											2024-07-30 17:51:02 +01:00
										 |  |  |     Homebrew.running_command = cmd | 
					
						
							| 
									
										
										
										
											2024-03-03 15:32:30 -08:00
										 |  |  |     if cmd_class | 
					
						
							| 
									
										
										
										
											2024-04-25 17:38:04 +01:00
										 |  |  |       command_instance = cmd_class.new | 
					
						
							| 
									
										
										
										
											2024-07-14 08:49:39 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |       require "utils/analytics" | 
					
						
							| 
									
										
										
										
											2024-04-25 17:38:04 +01:00
										 |  |  |       Utils::Analytics.report_command_run(command_instance) | 
					
						
							|  |  |  |       command_instance.run | 
					
						
							| 
									
										
										
										
											2024-03-03 15:32:30 -08:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2024-11-04 08:51:05 +00:00
										 |  |  |       begin | 
					
						
							|  |  |  |         Homebrew.public_send Commands.method_name(cmd) | 
					
						
							|  |  |  |       rescue NoMethodError => e | 
					
						
							|  |  |  |         case_error = "undefined method `#{cmd.downcase}' for module Homebrew" | 
					
						
							|  |  |  |         odie "Unknown command: brew #{cmd}" if e.message == case_error | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         raise | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2024-03-03 15:32:30 -08:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2020-02-02 17:05:45 +01:00
										 |  |  |   elsif (path = Commands.external_ruby_cmd_path(cmd)) | 
					
						
							| 
									
										
										
										
											2024-07-30 17:51:02 +01:00
										 |  |  |     Homebrew.running_command = cmd | 
					
						
							| 
									
										
										
										
											2020-02-02 17:05:45 +01:00
										 |  |  |     require?(path) | 
					
						
							|  |  |  |     exit Homebrew.failed? ? 1 : 0
 | 
					
						
							|  |  |  |   elsif Commands.external_cmd_path(cmd) | 
					
						
							| 
									
										
										
										
											2017-11-05 15:37:57 +00:00
										 |  |  |     %w[CACHE LIBRARY_PATH].each do |env| | 
					
						
							| 
									
										
										
										
											2023-12-18 09:34:01 -08:00
										 |  |  |       ENV["HOMEBREW_#{env}"] = Object.const_get(:"HOMEBREW_#{env}").to_s | 
					
						
							| 
									
										
										
										
											2010-02-27 13:29:49 +00:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |     exec "brew-#{cmd}", *ARGV | 
					
						
							| 
									
										
										
										
											2009-09-24 19:19:57 +01:00
										 |  |  |   else | 
					
						
							| 
									
										
										
										
											2024-07-14 08:49:39 -04:00
										 |  |  |     require "tap" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-04 17:05:37 +01:00
										 |  |  |     possible_tap = OFFICIAL_CMD_TAPS.find { |_, cmds| cmds.include?(cmd) } | 
					
						
							|  |  |  |     possible_tap = Tap.fetch(possible_tap.first) if possible_tap | 
					
						
							| 
									
										
										
										
											2015-11-07 16:52:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-21 13:19:54 -04:00
										 |  |  |     if !possible_tap || | 
					
						
							|  |  |  |        possible_tap.installed? || | 
					
						
							|  |  |  |        (blocked_tap = Tap.untapped_official_taps.include?(possible_tap.name)) | 
					
						
							| 
									
										
										
										
											2022-07-19 18:06:42 -04:00
										 |  |  |       if blocked_tap | 
					
						
							| 
									
										
										
										
											2022-07-21 13:19:54 -04:00
										 |  |  |         onoe <<~EOS | 
					
						
							|  |  |  |           `brew #{cmd}` is unavailable because #{possible_tap.name} was manually untapped. | 
					
						
							|  |  |  |           Run `brew tap #{possible_tap.name}` to reenable `brew #{cmd}`. | 
					
						
							|  |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2022-07-19 18:06:42 -04:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2022-02-11 10:49:21 -05:00
										 |  |  |       # Check for cask explicitly because it's very common in old guides | 
					
						
							|  |  |  |       odie "`brew cask` is no longer a `brew` command. Use `brew <command> --cask` instead." if cmd == "cask" | 
					
						
							| 
									
										
										
										
											2024-07-05 08:20:28 +01:00
										 |  |  |       odie "Unknown command: brew #{cmd}" | 
					
						
							| 
									
										
										
										
											2021-01-19 17:55:03 -05:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2017-09-24 20:12:58 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-18 08:47:52 -03:00
										 |  |  |     # Unset HOMEBREW_HELP to avoid confusing the tap | 
					
						
							| 
									
										
										
										
											2020-07-30 18:40:10 +02:00
										 |  |  |     with_env HOMEBREW_HELP: nil do | 
					
						
							|  |  |  |       tap_commands = [] | 
					
						
							| 
									
										
										
										
											2023-02-23 10:04:50 +00:00
										 |  |  |       if (File.exist?("/.dockerenv") || | 
					
						
							|  |  |  |          Homebrew.running_as_root? || | 
					
						
							| 
									
										
										
										
											2022-09-06 16:32:35 +01:00
										 |  |  |          ((cgroup = Utils.popen_read("cat", "/proc/1/cgroup").presence) && | 
					
						
							| 
									
										
										
										
											2023-02-23 10:04:50 +00:00
										 |  |  |           %w[azpl_job actions_job docker garden kubepods].none? { |type| cgroup.include?(type) })) && | 
					
						
							|  |  |  |          Homebrew.running_as_root_but_not_owned_by_root? | 
					
						
							|  |  |  |         tap_commands += %W[/usr/bin/sudo -u ##{Homebrew.owner_uid}] | 
					
						
							| 
									
										
										
										
											2020-07-30 18:40:10 +02:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2020-09-09 21:42:33 +02:00
										 |  |  |       quiet_arg = args.quiet? ? "--quiet" : nil | 
					
						
							|  |  |  |       tap_commands += [HOMEBREW_BREW_FILE, "tap", *quiet_arg, possible_tap.name] | 
					
						
							| 
									
										
										
										
											2020-07-30 18:40:10 +02:00
										 |  |  |       safe_system(*tap_commands) | 
					
						
							| 
									
										
										
										
											2019-04-18 07:48:05 +02:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2020-07-30 18:40:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 12:10:28 -04:00
										 |  |  |     ARGV << "--help" if help_flag | 
					
						
							| 
									
										
										
										
											2017-09-24 20:12:58 +01:00
										 |  |  |     exec HOMEBREW_BREW_FILE, cmd, *ARGV | 
					
						
							| 
									
										
										
										
											2009-06-02 13:39:39 +01:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2016-04-19 08:11:17 +02:00
										 |  |  | rescue UsageError => e | 
					
						
							| 
									
										
										
										
											2018-06-05 23:19:18 -04:00
										 |  |  |   require "help" | 
					
						
							| 
									
										
										
										
											2024-09-18 20:39:57 +00:00
										 |  |  |   Homebrew::Help.help cmd, remaining_args: args&.remaining || [], usage_error: e.message | 
					
						
							| 
									
										
										
										
											2015-12-21 08:44:41 +00:00
										 |  |  | rescue SystemExit => e | 
					
						
							| 
									
										
										
										
											2024-04-12 08:46:32 -07:00
										 |  |  |   onoe "Kernel.exit" if args&.debug? && !e.success? | 
					
						
							| 
									
										
										
										
											2024-07-15 13:44:01 -04:00
										 |  |  |   if args&.debug? || ARGV.include?("--debug") | 
					
						
							|  |  |  |     require "utils/backtrace" | 
					
						
							|  |  |  |     $stderr.puts Utils::Backtrace.clean(e) | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2009-11-11 18:51:05 +00:00
										 |  |  |   raise | 
					
						
							| 
									
										
										
										
											2017-05-05 10:50:26 +02:00
										 |  |  | rescue Interrupt | 
					
						
							| 
									
										
										
										
											2016-01-30 23:09:45 -08:00
										 |  |  |   $stderr.puts # seemingly a newline is typical | 
					
						
							| 
									
										
										
										
											2009-08-10 16:48:30 +01:00
										 |  |  |   exit 130
 | 
					
						
							| 
									
										
										
										
											2009-11-12 01:33:14 +00:00
										 |  |  | rescue BuildError => e | 
					
						
							| 
									
										
										
										
											2017-06-07 16:34:54 +01:00
										 |  |  |   Utils::Analytics.report_build_error(e) | 
					
						
							| 
									
										
										
										
											2024-04-03 20:17:02 -07:00
										 |  |  |   e.dump(verbose: args&.verbose? || false) | 
					
						
							| 
									
										
										
										
											2020-03-30 20:44:01 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-02 16:35:10 +01:00
										 |  |  |   if OS.unsupported_configuration? | 
					
						
							|  |  |  |     $stderr.puts "#{Tty.bold}Do not report this issue: you are running in an unsupported configuration.#{Tty.reset}" | 
					
						
							|  |  |  |   elsif e.formula.head? || e.formula.deprecated? || e.formula.disabled? | 
					
						
							| 
									
										
										
										
											2022-10-06 10:01:02 +01:00
										 |  |  |     reason = if e.formula.head? | 
					
						
							|  |  |  |       "was built from an unstable upstream --HEAD" | 
					
						
							|  |  |  |     elsif e.formula.deprecated? | 
					
						
							|  |  |  |       "is deprecated" | 
					
						
							|  |  |  |     elsif e.formula.disabled? | 
					
						
							|  |  |  |       "is disabled" | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2020-07-26 11:53:05 +02:00
										 |  |  |     $stderr.puts <<~EOS | 
					
						
							| 
									
										
										
										
											2022-10-06 10:01:02 +01:00
										 |  |  |       #{e.formula.name}'s formula #{reason}. | 
					
						
							|  |  |  |       This build failure is expected behaviour. | 
					
						
							|  |  |  |       Do not create issues about this on Homebrew's GitHub repositories. | 
					
						
							|  |  |  |       Any opened issues will be immediately closed without response. | 
					
						
							| 
									
										
										
										
											2023-02-17 14:33:53 +00:00
										 |  |  |       Do not ask for help from Homebrew or its maintainers on social media. | 
					
						
							| 
									
										
										
										
											2022-10-06 10:01:02 +01:00
										 |  |  |       You may ask for help in Homebrew's discussions but are unlikely to receive a response. | 
					
						
							|  |  |  |       Try to figure out the problem yourself and submit a fix as a pull request. | 
					
						
							|  |  |  |       We will review it but may or may not accept it. | 
					
						
							| 
									
										
										
										
											2020-07-26 11:53:05 +02:00
										 |  |  |     EOS | 
					
						
							| 
									
										
										
										
											2024-04-02 16:35:10 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-26 11:53:05 +02:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2020-03-30 20:44:01 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-12 01:33:14 +00:00
										 |  |  |   exit 1
 | 
					
						
							| 
									
										
										
										
											2024-04-04 08:51:27 +01:00
										 |  |  | rescue RuntimeError, SystemCallError => e | 
					
						
							|  |  |  |   raise if e.message.empty? | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-04 08:51:27 +01:00
										 |  |  |   onoe e | 
					
						
							| 
									
										
										
										
											2024-07-15 13:44:01 -04:00
										 |  |  |   if args&.debug? || ARGV.include?("--debug") | 
					
						
							|  |  |  |     require "utils/backtrace" | 
					
						
							|  |  |  |     $stderr.puts Utils::Backtrace.clean(e) | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2024-04-04 08:51:27 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   exit 1
 | 
					
						
							|  |  |  | rescue Exception => e # rubocop:disable Lint/RescueException | 
					
						
							| 
									
										
										
										
											2009-11-12 01:33:14 +00:00
										 |  |  |   onoe e | 
					
						
							| 
									
										
										
										
											2020-03-30 20:44:01 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-02 16:35:10 +01:00
										 |  |  |   method_deprecated_error = e.is_a?(MethodDeprecatedError) | 
					
						
							| 
									
										
										
										
											2024-07-14 08:49:39 -04:00
										 |  |  |   require "utils/backtrace" | 
					
						
							| 
									
										
										
										
											2024-04-04 08:51:27 +01:00
										 |  |  |   $stderr.puts Utils::Backtrace.clean(e) if args&.debug? || ARGV.include?("--debug") || !method_deprecated_error | 
					
						
							| 
									
										
										
										
											2024-04-02 16:35:10 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   if OS.unsupported_configuration? | 
					
						
							|  |  |  |     $stderr.puts "#{Tty.bold}Do not report this issue: you are running in an unsupported configuration.#{Tty.reset}" | 
					
						
							| 
									
										
										
										
											2024-04-03 19:44:12 +01:00
										 |  |  |   elsif Homebrew::EnvConfig.no_auto_update? && | 
					
						
							|  |  |  |         (fetch_head = HOMEBREW_REPOSITORY/".git/FETCH_HEAD") && | 
					
						
							|  |  |  |         (!fetch_head.exist? || (fetch_head.mtime.to_date < Date.today)) | 
					
						
							|  |  |  |     $stderr.puts "#{Tty.bold}You have disabled automatic updates and have not updated today.#{Tty.reset}" | 
					
						
							| 
									
										
										
										
											2024-04-02 16:35:10 +01:00
										 |  |  |     $stderr.puts "#{Tty.bold}Do not report this issue until you've run `brew update` and tried again.#{Tty.reset}" | 
					
						
							|  |  |  |   elsif (issues_url = (method_deprecated_error && e.issues_url) || Utils::Backtrace.tap_error_url(e)) | 
					
						
							|  |  |  |     $stderr.puts "If reporting this issue please do so at (not Homebrew/brew or Homebrew/homebrew-core):" | 
					
						
							|  |  |  |     $stderr.puts "  #{Formatter.url(issues_url)}" | 
					
						
							|  |  |  |   elsif internal_cmd | 
					
						
							| 
									
										
										
										
											2024-09-27 10:17:04 +08:00
										 |  |  |     $stderr.puts "#{Tty.bold}Please report this issue:#{Tty.reset}" | 
					
						
							|  |  |  |     $stderr.puts "  #{Formatter.url(OS::ISSUES_URL)}" | 
					
						
							| 
									
										
										
										
											2015-07-23 23:57:11 +02:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2024-04-02 16:35:10 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-23 09:32:04 +01:00
										 |  |  |   exit 1
 | 
					
						
							| 
									
										
										
										
											2012-03-15 10:57:34 +13:00
										 |  |  | else | 
					
						
							|  |  |  |   exit 1 if Homebrew.failed? | 
					
						
							| 
									
										
										
										
											2020-08-20 13:01:58 +01:00
										 |  |  | ensure | 
					
						
							|  |  |  |   if ENV["HOMEBREW_STACKPROF"] | 
					
						
							|  |  |  |     StackProf.stop | 
					
						
							|  |  |  |     StackProf.results("prof/stackprof.dump") | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2009-07-31 02:51:17 +01:00
										 |  |  | end |