Don't hang if xcode-select is set to "/"

This commit is contained in:
Max Howell 2012-02-20 18:24:36 +00:00
parent 6af4cc9f27
commit 2759dcf06b

View File

@ -317,7 +317,7 @@ module MacOS extend self
@xcode_prefix ||= begin
path = `/usr/bin/xcode-select -print-path 2>/dev/null`.chomp
path = Pathname.new path
if path.directory? and path.absolute?
if $?.success? and path.directory? and path.absolute?
path
elsif File.directory? '/Developer'
# we do this to support cowboys who insist on installing
@ -343,9 +343,12 @@ module MacOS extend self
def xcode_version
@xcode_version ||= begin
# Xcode 4.3 xc* tools hang indefinately if xcode-select path is set thus
raise if `xcode-select -print-path 2>/dev/null`.chomp == "/"
raise unless system "/usr/bin/which -s xcodebuild"
`xcodebuild -version 2>&1` =~ /Xcode (\d(\.\d)*)/
raise if $1.nil?
`xcodebuild -version 2>/dev/null` =~ /Xcode (\d(\.\d)*)/
raise if $1.nil? or not $?.success?
$1
rescue
# for people who don't have xcodebuild installed due to using