Homebrew 找不到已安装的命令行工具

Homebrew cannot find installed command line tools

我已经通过 Xcode 安装了命令行工具。当我运行xcode-select -p时,显示/Applications/Xcode.app/Contents/Developer.

但是,当我运行brew config时,它显示CLT: N/A。当我使用 brew 更新 python 时,它显示 Warning: Building python from source: The bottle needs the Apple Command Line Tools to be installed.

我刚才遇到了同样的问题。 运行 xcode-select --install 重新安装命令行工具对我有用,brew config 现在报告 CLT: 7.3.1.0.1.1461711523

因为xcode-select --install没有解决我的问题:

我不得不 运行 brew doctor 列出 Warning: Some installed formula are missing dependencies. 包括 brew install 命令来修复这些问题。 运行之后,brew config 报告 CLT 不再是 N/A

使用 sudo xcode-select --switch path/to/Xcode.app 指定您希望用于命令行开发人员工具的 Xcode,或使用 xcode-select --install 安装独立的命令行开发人员工具。

对于上面相同的dependency issue, xcode-select --install 并单击 pop-up fixes this in MacOS Catalina. Once complete, you can confirm it by typing xcode-select -v in the terminal and the output should look similar to this

上的 "Install"

如果您已经安装了 CLI 工具的独立版本(并且没有完整的 xcode 应用程序):

sudo xcode-select --switch /Library/Developer/CommandLineTools

(路径由 提供)