troubles when I use homebrew

2020-01-29 05:15发布

问题:

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!

回答1:

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.



回答2:

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.