1. 程式人生 > >Macos下的xcrun error:invalid active developer path

Macos下的xcrun error:invalid active developer path

問題的提出

在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分鐘左右,依據網速不同而有差異。
在安裝過程中,有可能會發現如下問題:
install error
針對這個問題,可以採用如下方式處理:
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