14

I want to install git in my Mac(OS X 10.10.3).I write: brew install git

but it reported :

sh: line 1:  1549 Abort trap: 6           /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk / -find clang 2> /dev/null
clang: error: unable to find utility "clang", not a developer tool or in PATH
sh: line 1:  1552 Abort trap: 6           /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk / -find otool 2> /dev/null
otool: error: unable to find utility "otool", not a developer tool or in PATH
Error: Failure while executing: /usr/bin/otool -L /usr/bin/install_name_tool

then I write brew doctor. it reported:

Warning: /usr/local/include isn't writable.

This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.

You should probably `chown` /usr/local/include

Warning: /usr/local/lib isn't writable.

This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.

You should probably `chown` /usr/local/lib
sh: line 1:  1318 Abort trap: 6           /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk / -find otool 2> /dev/null
otool: error: unable to find utility "otool", not a developer tool or in PATH
Error: Failure while executing: /usr/bin/otool -L /usr/bin/install_name_tool

then I chown the lib and include with "sudo chown 755 include""sudo chown 755 lib" the first and second warning are removed but the third is still there.

And what confused me more is that in my finder:/usr/local/ the "include" and "lib" which should be folders but become files. how can I slove the error "cannot find otool" and install git with brew and

why my lib and include folder become files?... thanks for your help!

Shawn
  • 167
  • 1
  • 1
  • 10
  • This should probably be a bugreport on the issue tracker. – Nick Volynkin Jun 11 '15 at 21:25
  • 1
    Your Xcode environment is broken. If /usr/bin/clang is missing, you should reinstall OS X. If it's present, you should make sure `xcode-select -p` points to a Developer path. Failing that, you should reinstall either Xcode or the Xcode Command Line Tools. – Tim Smith Jun 12 '15 at 00:37
  • @TimSmith thanks for help. In /usr/bin/clang is still present. And the 'xcode-select -p' points to /Applications/Xcode.app/Contents/Developer. I cannot understand why my two folders become files. It is confusing. Because I have no problem running program in my xcode. Someone suggests reinstall the homebrew. I don't know what to do? Can you explain a little? – Shawn Jun 12 '15 at 05:29
  • @NickVolynkin Sorry, I am new on Mac. Any suggestions to me about what I should do then ? – Shawn Jun 12 '15 at 05:31
  • @Shawn I meant the Homebrew issue tracker on GitHub. But since Tim Smith is a Homebrew maintainer, there's no need to do that. – Nick Volynkin Jun 14 '15 at 19:14
  • I'm having the same problem on 10.10.3. It's not only Homebrew, I have this issues just with the `git` command and other tools from `/Applications/Xcode.app/Contents/Developer/usr/bin/`. – Ivan Mir Jun 17 '15 at 02:32

2 Answers2

65

The problem is that Xcode is unable to find its own Command Line Tools for some reason:

sh: line 1:  1549 Abort trap: 6      /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk / -find clang 2> /dev/null
clang: error: unable to find utility "clang", not a developer tool or in PATH

Check out xcode-select --print-path in your Terminal.

If it's /Applications/Xcode.app/Contents/Developer then run sudo xcode-select --switch /Library/Developer/CommandLineTools to set xcode-select to non-Xcode Command Line Tools.

In case you don't have /Library/Developer/CommandLineTools directory, you can get them at https://developer.apple.com/downloads/ for your current Xcode version.

Ivan Mir
  • 1,209
  • 1
  • 12
  • 32
1

First. Maybe you should update the homebrew before you install:

brew update

Second. Maybe this instruction helps ( taken from the Ask Different ). At least it's useful when you solve your problem:

      brew install git
      $ git --version
           git version 1.7.12.4 (Apple Git-37)
      $ which git
           /usr/bin/git
      **// doh! osx's pre-installed git trumps the brew one, so:**
      $ sudo mv /usr/bin/git /usr/bin/git-apple
      $ which git
           /usr/local/bin/git
      $ git --version
           git version 1.8.2
      // ok cool.
Community
  • 1
  • 1
Nick Volynkin
  • 14,023
  • 6
  • 43
  • 67