From 4aed55cccb162b842b0127973e58db405793e5ef Mon Sep 17 00:00:00 2001
From: samueljohn <github@samueljohn.de>
Date: Tue, 26 Jun 2012 12:19:12 +0200
Subject: [PATCH] doctor: suggest the correct xcode-select path to the user

Shortened the part about the CLT-only systems, because this message is
never shown to them.

Closes Homebrew/homebrew#13061.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
---
 Library/Homebrew/cmd/doctor.rb | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb
index 8cbbf83fa6..99cc096a23 100644
--- a/Library/Homebrew/cmd/doctor.rb
+++ b/Library/Homebrew/cmd/doctor.rb
@@ -403,27 +403,15 @@ def check_xcode_prefix
 end
 
 def check_xcode_select_path
-  path = `xcode-select -print-path 2>/dev/null`.chomp
   # with the advent of CLT-only support, we don't need xcode-select
   return if MacOS.clt_installed?
-  unless File.directory? path and File.file? "#{path}/usr/bin/xcodebuild" and not MacOS.xctools_fucked?
-    # won't guess at the path they should use because it's too hard to get right
-    # We specify /Applications/Xcode.app/Contents/Developer even though
-    # /Applications/Xcode.app should work because people don't install the new CLI
-    # tools and then it doesn't work. Lets hope the location doesn't change in the
-    # future.
-
+  unless File.file? "#{MacOS.xcode_folder}/usr/bin/xcodebuild" and not MacOS.xctools_fucked?
+    path = MacOS.app_with_bundle_id(MacOS::XCODE_4_BUNDLE_ID) or MacOS.app_with_bundle_id(MacOS::XCODE_3_BUNDLE_ID)
+    path = '/Developer' if path.nil? or not path.directory?
     <<-EOS.undent
       Your Xcode is configured with an invalid path.
-      You should change it to the correct path. Please note that there is no correct
-      path at this time if you have *only* installed the Command Line Tools for Xcode.
-      If your Xcode is pre-4.3 or you installed the whole of Xcode 4.3 then one of
-      these is (probably) what you want:
-
-          sudo xcode-select -switch /Developer
-          sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
-
-      DO NOT SET / OR EVERYTHING BREAKS!
+      You should change it to the correct path:
+        sudo xcode-select -switch #{path}
     EOS
   end
 end
-- 
GitLab