Skip to content

Commit

Permalink
Fixed an error where gcc was available, but brew failed because it …
Browse files Browse the repository at this point in the history
…has checked for XCode presence

The error was: "undefined method `<' for nil:NilClass", coming from Library/Homebrew/extend/ENV.rb:140

This prevented installing for users who have downloaded "standalone" compilers
eg. from <https://github.com/kennethreitz/osx-gcc-installer>.
  • Loading branch information
karmi committed Sep 2, 2011
1 parent 3f4ef7e commit 64ad3d2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Library/Homebrew/cmd/doctor.rb
Expand Up @@ -195,6 +195,8 @@ def check_gcc_versions
end end


if MacOS.xcode_version == nil if MacOS.xcode_version == nil
# TODO: Do better detection of gcc etc., or display proper instructions for
# installing eg. <https://github.com/kennethreitz/osx-gcc-installer>
puts <<-EOS.undent puts <<-EOS.undent
We couldn't detect any version of Xcode. We couldn't detect any version of Xcode.
If you downloaded Xcode 4.1 from the App Store, you may need to run the installer. If you downloaded Xcode 4.1 from the App Store, you may need to run the installer.
Expand Down
10 changes: 5 additions & 5 deletions Library/Homebrew/extend/ENV.rb
Expand Up @@ -120,10 +120,10 @@ def gcc_4_0_1
alias_method :gcc_4_0, :gcc_4_0_1 alias_method :gcc_4_0, :gcc_4_0_1
def gcc def gcc
if MacOS.xcode_version < '4' if MacOS.xcode_version.to_s < '4'
self['CC'] = '/usr/bin/cc' self['CC'] = '/usr/bin/cc'
self['CXX'] = '/usr/bin/c++' self['CXX'] = '/usr/bin/c++'
elsif MacOS.xcode_version >= '4.2' elsif MacOS.xcode_version.to_s >= '4.2'
# Apple stopped adding the -4.2 suffixes # Apple stopped adding the -4.2 suffixes
self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/gcc" self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/gcc"
self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/g++" self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/g++"
Expand All @@ -137,9 +137,9 @@ def gcc
alias_method :gcc_4_2, :gcc alias_method :gcc_4_2, :gcc
def llvm def llvm
if MacOS.xcode_version < '4' if MacOS.xcode_version.to_s < '4'
self.gcc self.gcc
elsif MacOS.xcode_version < '4.1' elsif MacOS.xcode_version.to_s < '4.1'
self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/llvm-gcc" self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/llvm-gcc"
self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/llvm-g++" self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/llvm-g++"
else else
Expand All @@ -149,7 +149,7 @@ def llvm
end end
def clang def clang
if MacOS.xcode_version > '4' if MacOS.xcode_version.to_s > '4'
self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/clang" self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/clang"
self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/clang++" self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/clang++"
else else
Expand Down

0 comments on commit 64ad3d2

Please sign in to comment.