我使用自制软件时遇到的麻烦

troubles when I use homebrew

我想在我的 Mac(OS X 10.10.3) 中安装 git。我写:brew install git

但它报告:

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

然后我写 brew doctor。它报道:

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

然后我 chown 库并包含 "sudo chown 755 include""sudo chown 755 lib" 第一个和第二个警告已删除,但第三​​个警告仍然存在。

更让我困惑的是,在我的查找器中:/usr/local/ "include" 和 "lib" 应该是文件夹,但变成了文件。 我如何解决错误 "cannot find otool" 并使用 brew 安装 git 和

为什么我的 lib 和 include 文件夹变成了文件?...感谢您的帮助!

首先。也许你应该在安装之前更新自制软件:

brew update

其次。也许这条指令有帮助(取自 Ask Different )。至少对你解决问题有用:

      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.

问题是 Xcode 由于某种原因无法找到自己的命令行工具:

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

在您的终端中查看 xcode-select --print-path

如果是 /Applications/Xcode.app/Contents/Developer,则 运行 sudo xcode-select --switch /Library/Developer/CommandLineTools 将 xcode-select 设置为非 Xcode 命令行工具。

如果您没有 /Library/Developer/CommandLineTools 目录,您可以在 https://developer.apple.com/downloads/ 获取当前 Xcode 版本的目录。