Command Line Tools路径错误
MacOS升级后,经常碰到Invalid path to Command Line Tools
的错误
比如你在用IDEA之类的IDE,右下角弹出
此时打开终端,输入git --version
,会提示如下错误:
xxx@xxx-mac ~ % git --version
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
如何解决?
输入命令
xxx@xxx-mac ~ % xcode-select --install
会弹窗提示
点击“安装”,根据提示安装即可。
验证一下
xxx@xxx-mac ~ % git --version
git version 2.24.3 (Apple Git-128)
问题解决。
如果你不幸,上述命令无效,那么试试
xxx@xxx-mac ~ % xcode-select --reset
什么是xcode-select
Print or change the path to the active developer directory. This directory controls which tools are used for the Xcode command line tools (for example, xcodebuild) as well as the BSD development commands (such as cc and make).
顾名思义,xcode-select
用于选择Command Line Tools
的路径。
xxx@xxx-mac ~ % xcode-select -p
/Library/Developer/CommandLineTools
xxx@xxx-mac CommandLineTools % ls /Library/Developer/CommandLineTools/usr/bin
一些开发工具,如gcc, g++, git, python3, pip3, swift等等,全在这个目录下。
飞鱼原创 https://ffish.net,未经允许,严禁转载!