From 775406be912824881d09230cfbaaea8245431ffd Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Fri, 13 Dec 2013 08:28:49 -0800 Subject: [PATCH] brew: error out if bad xcode-select path given Since a bad xcode-select path can cause many brew commands to freeze, it's worth warning users and bailing out as early as possible. The doctor check wasn't good enough, since the doctor could freeze before the warning about this was ever printed. --- Library/Homebrew/cmd/doctor.rb | 10 +--------- Library/brew.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb index e1dbf16789..62d266c083 100644 --- a/Library/Homebrew/cmd/doctor.rb +++ b/Library/Homebrew/cmd/doctor.rb @@ -437,15 +437,7 @@ def check_xcode_prefix_exists end def check_xcode_select_path - # with the advent of CLT-only support, we don't need xcode-select - - if MacOS::Xcode.bad_xcode_select_path? - <<-EOS.undent - Your xcode-select path is set to / - You must unset it or builds will hang: - sudo rm /usr/share/xcode-select/xcode_dir_* - EOS - elsif not MacOS::CLT.installed? and not File.file? "#{MacOS::Xcode.folder}/usr/bin/xcodebuild" + if not MacOS::CLT.installed? and not File.file? "#{MacOS::Xcode.folder}/usr/bin/xcodebuild" path = MacOS.app_with_bundle_id(MacOS::Xcode::V4_BUNDLE_ID) || MacOS.app_with_bundle_id(MacOS::Xcode::V3_BUNDLE_ID) path = '/Developer' if path.nil? or not path.directory? <<-EOS.undent diff --git a/Library/brew.rb b/Library/brew.rb index 4fa22b4ee0..6a2369b460 100755 --- a/Library/brew.rb +++ b/Library/brew.rb @@ -16,6 +16,22 @@ $:.unshift(HOMEBREW_LIBRARY_PATH + '/vendor') $:.unshift(HOMEBREW_LIBRARY_PATH) require 'global' +# Check for bad xcode-select before anything else, because `doctor` and +# many other things will hang +# Note that this bug was fixed in 10.9 +if `xcode-select -print-path 2>/dev/null`.chomp == '/' && MacOS.version < :mavericks + ofail <<-EOS.undent + Your xcode-select path is currently set to '/'. + This causes the `xcrun` tool to hang, and can render Homebrew unusable. + If you are using Xcode, you should: + sudo xcode-select -switch /Applications/Xcode.app + Otherwise, you should: + sudo rm -rf /usr/share/xcode-select + EOS + + exit -1 +end + case ARGV.first when '-h', '--help', '--usage', '-?', 'help', nil require 'cmd/help' puts Homebrew.help_s