问题的提出
在macos下想使用brew安装某个文件,结果得到了如下错误信息:
执行命令: brew install mpv
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Error: Failure while executing; `git config --local --replace-all homebrew.private true` exited with 1.
问题的分析
执行了如下命令:
brew update
结果显示:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Error: Failure while executing; `git config --local --replace-all homebrew.private true` exited with 1.
ZBMAC-C02W25PEH:Downloads chenjunfeng1$ brew update
Already up-to-date.
可以断定,这个应该是某个配置的错误问题造成的。
问题的解决
于是只好求助于google了,经过一番查找,有人建议使用如下命令:
sudo xcode-select --install
提示如下界面,这是一个安装提示:
![在这里插入图片描述](https://img-blog.csdnimg.cn/20181028162049674.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2JsdWVoZWFydDIw,size_27,color_FFFFFF,t_70)
整个过程会持续大约3分钟左右,依据网速不同而有差异。
在安装过程中,有可能会发现如下问题:
针对这个问题,可以采用如下方式处理:
1)升级xcode到最新版本,然后执行xcode-select –install
主要原因是由于在macos升级之后,当前xcode版本比较低。所以升级一下即可。
2)或者去developer apple网站上手工下载
https://developer.apple.com/download/more/
安装成功后,就可以基于brew正常安装软件了。
brew install wget
==> Installing dependencies for wget: libidn2
==> Installing wget dependency: libidn2
==> Downloading https://homebrew.bintray.com/bottles/libidn2-2.0.5.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libidn2-2.0.5.mojave.bottle.tar.gz
? /usr/local/Cellar/libidn2/2.0.5: 68 files, 669KB
==> Installing wget
==> Downloading https://homebrew.bintray.com/bottles/wget-1.19.5.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring wget-1.19.5.mojave.bottle.tar.gz
? /usr/local/Cellar/wget/1.19.5: 50 files, 3.7MB
总结
原因是xcode缺少了一个组件,这里安装即可。