| 
									
										
										
										
											2016-04-08 16:28:43 +02:00
										 |  |  | #:  * `doctor`: | 
					
						
							|  |  |  | #:    Check your system for potential problems. Doctor exits with a non-zero status | 
					
						
							|  |  |  | #:    if any problems are found. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-18 17:39:21 -04:00
										 |  |  | # Undocumented options: | 
					
						
							|  |  |  | #     -D activates debugging and profiling of the audit methods (not the same as --debug) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-04 23:14:58 +01:00
										 |  |  | require "diagnostic" | 
					
						
							| 
									
										
										
										
											2012-03-01 16:32:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-18 22:41:47 -05:00
										 |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2016-09-26 01:44:51 +02:00
										 |  |  |   module_function | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-09 13:00:33 +00:00
										 |  |  |   def doctor | 
					
						
							| 
									
										
										
										
											2016-04-18 17:39:21 -04:00
										 |  |  |     inject_dump_stats!(Diagnostic::Checks, /^check_*/) if ARGV.switch? "D" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-04 23:14:58 +01:00
										 |  |  |     checks = Diagnostic::Checks.new | 
					
						
							| 
									
										
										
										
											2012-03-01 16:32:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     if ARGV.include? "--list-checks" | 
					
						
							| 
									
										
										
										
											2014-09-07 14:20:37 -05:00
										 |  |  |       puts checks.all.sort | 
					
						
							| 
									
										
										
										
											2012-11-13 16:49:43 -06:00
										 |  |  |       exit | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-07 14:20:37 -05:00
										 |  |  |     if ARGV.named.empty? | 
					
						
							| 
									
										
										
										
											2016-01-02 01:03:54 +01:00
										 |  |  |       slow_checks = %w[
 | 
					
						
							|  |  |  |         check_for_broken_symlinks | 
					
						
							|  |  |  |         check_missing_deps | 
					
						
							|  |  |  |         check_for_linked_keg_only_brews | 
					
						
							|  |  |  |       ] | 
					
						
							|  |  |  |       methods = (checks.all.sort - slow_checks) + slow_checks | 
					
						
							| 
									
										
										
										
											2012-08-14 11:21:33 -04:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2014-09-07 14:20:37 -05:00
										 |  |  |       methods = ARGV.named | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2012-08-14 11:21:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-29 11:14:46 -07:00
										 |  |  |     first_warning = true | 
					
						
							| 
									
										
										
										
											2012-08-14 11:21:33 -04:00
										 |  |  |     methods.each do |method| | 
					
						
							| 
									
										
										
										
											2016-08-16 11:16:37 +01:00
										 |  |  |       $stderr.puts "Checking #{method}" if ARGV.debug? | 
					
						
							| 
									
										
										
										
											2016-01-05 15:53:57 +01:00
										 |  |  |       unless checks.respond_to?(method) | 
					
						
							| 
									
										
										
										
											2014-11-26 17:54:53 -08:00
										 |  |  |         Homebrew.failed = true | 
					
						
							|  |  |  |         puts "No check available by the name: #{method}" | 
					
						
							|  |  |  |         next | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2016-01-05 15:53:57 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |       out = checks.send(method) | 
					
						
							| 
									
										
										
										
											2016-09-10 10:24:56 +01:00
										 |  |  |       next if out.nil? || out.empty? | 
					
						
							|  |  |  |       if first_warning | 
					
						
							|  |  |  |         $stderr.puts <<-EOS.undent
 | 
					
						
							| 
									
										
										
										
											2016-08-30 21:38:13 +02:00
										 |  |  |           #{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 and just ignore them. Thanks!#{Tty.reset} | 
					
						
							| 
									
										
										
										
											2016-09-10 10:24:56 +01:00
										 |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2012-03-01 16:32:02 +00:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2016-09-10 10:24:56 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |       $stderr.puts | 
					
						
							|  |  |  |       opoo out | 
					
						
							|  |  |  |       Homebrew.failed = true | 
					
						
							|  |  |  |       first_warning = false | 
					
						
							| 
									
										
										
										
											2011-05-21 03:40:48 +02:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2010-11-09 13:00:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-12 19:30:56 -05:00
										 |  |  |     puts "Your system is ready to brew." unless Homebrew.failed? | 
					
						
							| 
									
										
										
										
											2010-03-31 14:55:41 -07:00
										 |  |  |   end | 
					
						
							|  |  |  | end |