From 2ca6dbbe9d94b5d295f46f7a1d3a12ade3aa3f08 Mon Sep 17 00:00:00 2001 From: Elliot Saba <staticfloat@gmail.com> Date: Wed, 8 Jun 2016 05:53:10 -0700 Subject: [PATCH] brew.rb: Don't ask `xcrun` for output if no CLT is installed (#334) This avoids `xcrun` popups when installing Homebrew on a non-Xcode non-CLT machine. --- Library/brew.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Library/brew.sh b/Library/brew.sh index f65b7f63d2..8d55601c0f 100644 --- a/Library/brew.sh +++ b/Library/brew.sh @@ -137,7 +137,8 @@ export HOMEBREW_USER_AGENT_CURL if [[ -n "$HOMEBREW_OSX" ]] then - if [[ "$('/usr/bin/xcode-select' --print-path)" = "/" ]] + XCODE_SELECT_PATH=$('/usr/bin/xcode-select' --print-path 2>/dev/null) + if [[ "$XCODE_SELECT_PATH" = "/" ]] then odie <<EOS Your xcode-select path is currently set to '/'. @@ -149,15 +150,20 @@ Otherwise, you should: EOS fi - XCRUN_OUTPUT="$(/usr/bin/xcrun clang 2>&1)" - XCRUN_STATUS="$?" - - if [[ "$XCRUN_STATUS" -ne 0 && "$XCRUN_OUTPUT" = *license* ]] + # Don't check xcrun if Xcode and the CLT aren't installed, as that opens + # a popup window asking the user to install the CLT + if [[ -n "$XCODE_SELECT_PATH" ]] then - odie <<EOS + XCRUN_OUTPUT="$(/usr/bin/xcrun clang 2>&1)" + XCRUN_STATUS="$?" + + if [[ "$XCRUN_STATUS" -ne 0 && "$XCRUN_OUTPUT" = *license* ]] + then + odie <<EOS You have not agreed to the Xcode license. Please resolve this by running: sudo xcodebuild -license EOS + fi fi fi -- GitLab