| 
									
										
										
										
											2024-03-29 18:21:13 -07:00
										 |  |  | # typed: strict | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 18:21:13 -07:00
										 |  |  | require "abstract_command" | 
					
						
							| 
									
										
										
										
											2016-01-04 23:14:58 +01:00
										 |  |  | require "diagnostic" | 
					
						
							| 
									
										
										
										
											2020-07-10 10:36:59 -04:00
										 |  |  | require "cask/caskroom" | 
					
						
							| 
									
										
										
										
											2012-03-01 16:32:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-18 22:41:47 -05:00
										 |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2024-03-29 18:21:13 -07:00
										 |  |  |   module Cmd | 
					
						
							|  |  |  |     class Doctor < AbstractCommand | 
					
						
							|  |  |  |       cmd_args do | 
					
						
							|  |  |  |         description <<~EOS | 
					
						
							|  |  |  |           Check your system for potential problems. Will exit with a non-zero status | 
					
						
							|  |  |  |           if any potential problems are found. | 
					
						
							| 
									
										
										
										
											2023-09-11 02:29:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 18:21:13 -07:00
										 |  |  |           Please note that these warnings are just used to help the Homebrew maintainers | 
					
						
							|  |  |  |           with debugging if you file an issue. If everything you use Homebrew for | 
					
						
							|  |  |  |           is working fine: please don't worry or file an issue; just ignore this. | 
					
						
							|  |  |  |         EOS | 
					
						
							|  |  |  |         switch "--list-checks", | 
					
						
							|  |  |  |                description: "List all audit methods, which can be run individually " \ | 
					
						
							|  |  |  |                             "if provided as arguments." | 
					
						
							|  |  |  |         switch "-D", "--audit-debug", | 
					
						
							|  |  |  |                description: "Enable debugging and profiling of audit methods." | 
					
						
							| 
									
										
										
										
											2021-01-10 14:26:40 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 18:21:13 -07:00
										 |  |  |         named_args :diagnostic_check | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2018-10-24 15:58:35 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 18:21:13 -07:00
										 |  |  |       sig { override.void } | 
					
						
							|  |  |  |       def run | 
					
						
							|  |  |  |         Homebrew.inject_dump_stats!(Diagnostic::Checks, /^check_*/) if args.audit_debug? | 
					
						
							| 
									
										
										
										
											2018-10-24 15:58:35 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 18:21:13 -07:00
										 |  |  |         checks = Diagnostic::Checks.new(verbose: args.verbose?) | 
					
						
							| 
									
										
										
										
											2016-04-18 17:39:21 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 18:21:13 -07:00
										 |  |  |         if args.list_checks? | 
					
						
							|  |  |  |           puts checks.all | 
					
						
							|  |  |  |           return | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2012-03-01 16:32:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 18:21:13 -07:00
										 |  |  |         if args.no_named? | 
					
						
							|  |  |  |           slow_checks = %w[
 | 
					
						
							|  |  |  |             check_for_broken_symlinks | 
					
						
							|  |  |  |             check_missing_deps | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  |           methods = (checks.all - slow_checks) + slow_checks | 
					
						
							|  |  |  |           methods -= checks.cask_checks unless Cask::Caskroom.any_casks_installed? | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |           methods = args.named | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2012-11-13 16:49:43 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 18:21:13 -07:00
										 |  |  |         first_warning = T.let(true, T::Boolean) | 
					
						
							|  |  |  |         methods.each do |method| | 
					
						
							|  |  |  |           $stderr.puts Formatter.headline("Checking #{method}", color: :magenta) if args.debug? | 
					
						
							|  |  |  |           unless checks.respond_to?(method) | 
					
						
							|  |  |  |             ofail "No check available by the name: #{method}" | 
					
						
							|  |  |  |             next | 
					
						
							|  |  |  |           end | 
					
						
							| 
									
										
										
										
											2012-08-14 11:21:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 18:21:13 -07:00
										 |  |  |           out = checks.send(method) | 
					
						
							|  |  |  |           next if out.blank? | 
					
						
							| 
									
										
										
										
											2016-01-05 15:53:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 18:21:13 -07:00
										 |  |  |           if first_warning | 
					
						
							|  |  |  |             $stderr.puts <<~EOS | 
					
						
							|  |  |  |               #{Tty.bold}Please note that these warnings are just used to help the Homebrew maintainers | 
					
						
							|  |  |  |               with debugging if you file an issue. If everything you use Homebrew for is | 
					
						
							|  |  |  |               working fine: please don't worry or file an issue; just ignore this. Thanks!#{Tty.reset} | 
					
						
							|  |  |  |             EOS | 
					
						
							|  |  |  |           end | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 18:21:13 -07:00
										 |  |  |           $stderr.puts | 
					
						
							|  |  |  |           opoo out | 
					
						
							|  |  |  |           Homebrew.failed = true | 
					
						
							|  |  |  |           first_warning = false | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2016-09-10 10:24:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 18:21:13 -07:00
										 |  |  |         puts "Your system is ready to brew." if !Homebrew.failed? && !args.quiet? | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2011-05-21 03:40:48 +02:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2010-03-31 14:55:41 -07:00
										 |  |  |   end | 
					
						
							|  |  |  | end |