aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rwxr-xr-xLibrary/brew.rb40
1 files changed, 26 insertions, 14 deletions
diff --git a/Library/brew.rb b/Library/brew.rb
index 886b07910..e0e9673a9 100755
--- a/Library/brew.rb
+++ b/Library/brew.rb
@@ -25,18 +25,30 @@ elsif ARGV.first == "-v"
exit 0 if ARGV.length == 1
end
-# 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 OS.mac? && MacOS.version < :mavericks && MacOS.active_developer_dir == "/"
- odie <<-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
+if OS.mac?
+ # Check for bad xcode-select before other checks, because `doctor` and
+ # many other things will hang. Note that this bug was fixed in 10.9
+ if MacOS.version < :mavericks && MacOS.active_developer_dir == "/"
+ odie <<-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
+ end
+
+ # Check for user agreement of the Xcode license before permitting
+ # any other brew usage to continue. This prevents the situation where
+ # people are instructed to "please re-run as root via sudo" on brew commands.
+ # The check can only fail when Xcode is installed & the active developer dir.
+ if MacOS::Xcode.installed? && `/usr/bin/xcrun clang 2>&1` =~ /license/ && !$?.success?
+ odie <<-EOS.undent
+ You have not agreed to the Xcode license. Please resolve this by running:
+ sudo xcodebuild -license
+ EOS
+ end
end
case HOMEBREW_PREFIX.to_s
@@ -45,7 +57,7 @@ when "/", "/usr"
abort "Cowardly refusing to continue at this prefix: #{HOMEBREW_PREFIX}"
end
-if OS.mac? and MacOS.version < "10.6"
+if OS.mac? && MacOS.version < "10.6"
abort <<-EOABORT.undent
Homebrew requires Snow Leopard or higher. For Tiger and Leopard support, see:
https://github.com/mistydemeo/tigerbrew
@@ -88,7 +100,7 @@ begin
sudo_check = %w[ install link pin unpin upgrade ]
if sudo_check.include? cmd
- if Process.uid.zero? and not File.stat(HOMEBREW_BREW_FILE).uid.zero?
+ if Process.uid.zero? && !File.stat(HOMEBREW_BREW_FILE).uid.zero?
raise <<-EOS.undent
Cowardly refusing to `sudo brew #{cmd}`
You can use brew with sudo, but only if the brew executable is owned by root.