Mac下xcrun: error: invalid active developer path問題解決方法
阿新 • • 發佈:2019-01-02
引言: Mac系統下執行git之時的錯誤問題之解決辦法
問題起源
在mac下,需要下載github下的某個專案:
git clone xxx
但是報出了錯誤資訊。錯誤資訊如下:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
問題分析
初步懷疑是git的問題,所以,嘗試檢視git的幫助資訊:
git -h
結果仍然報出類似的錯誤資訊:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
嘗試檢查一下git是否已經正確安裝:
which git
/usr/bin/git
提示git已經被正確安裝好了。
問題再次分析
是否是git的安裝包被破壞了呢?於是嘗試重新安裝一下:
brew install git
結果報出如下的錯誤資訊:
Error: The following formula:
git
cannot be installed as a binary package and must be built from source.
Install the Command Line Tools:
xcode-select --install
Error: Git must be installed and in your PATH!
Error: The following formula:
git
cannot be installed as a binary package and must be built from source.
Install the Command Line Tools:
xcode-select --install
驚奇地發現brew提示瞭如下資訊,需要xcode-select重新安裝。
於是執行安裝xcode-select指令:
xcode-select –install
結果
在xcode-select指令安裝好之後,在命令檢查一下git指令的幫助資訊:
git -h
可以正確輸出相應的幫助資訊,意味著git已經被修復好了。