命令行工具不能正常工作 – OS X El Capitan / macOS Sierra / macOS High Sierra

我刚刚从优胜美地升级到了El Capitan(并且复制了从El Capitan升级到Sierra的问题),当我尝试在terminal中键入例如git status ,出现以下错误:

 xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun 

我没有安装Xcode,从来没有。 任何人都有解决scheme?

find了解决这个问题的方法。

 xcode-select --install 

这将提示安装必要的命令行工具。

如果您在xcode-select --install命令中遇到问题, 例如,我一直在networking问题超时,然后尝试下载dmg在developercode.apple.com/downloads (命令行工具OS X 10.11)的Xcode 7.1

我试过的解决schemexcode-select --install但它不帮助我,我从塞拉利昂更新到高发生了这个,我的解决scheme:

 sudo xcode-select --reset 

我用cocoapods重新安装解决了它

 sudo gem install cocoapods 

我刚更新到高层,我不能只运行xcode-select --install 。 首先,我不得不从应用程序商店实际安装xcode。 然后我运行xcode-select --install 。 然后我必须运行sudo xcodebuild -license ,同意这些条款,然后我可以再次运行git命令。