我更新了最新的操作系统,和/或重新启动了我的计算机(每次重大更新都会发生这种情况,但这次我所做的只是在2022-09-13年重新启动我的计算机)

今天早上,我在MacBook pro的命令行中导航到我的工作代码库,在存储库中键入“gitstatus”,收到一个错误:

(2022年9月,这个错误大不相同,但我没有捕捉到它)

xcrun:错误:无效的活动开发人员路径(/Library/developer/CommandLineTools),在以下位置缺少xcrun:/Librari/developer/CommandLineTools/usr/bin/xcrun

git不起作用!

如何修复git和命令行工具?


当前回答

除了dustbuster的答案,我还需要使用以下命令设置Xcode文件夹的路径:

sudo xcode-select -switch /Library/Developer/CommandLineTools

其他回答

这对我有用

sudo xcode-select --reset 
sudo xcodebuild -license

必须安装X代码。

如果您在外部驱动器中创建了一个新的应用程序文件夹并在那里安装了Xcode:

sudo xcode-select --switch /Volumes/MyExternalStorageName/Applications/Xcode.app/Contents/Developer

打开终端:

安装XCode开发人员工具并解决问题。

$ xcode-select --install

如果您有多个版本,请将路径重置为Xcode:

$ xcode-select --switch /Applications/Xcode.app
$ xcode-select --switch /Library/Developer/CommandLineTools

如果您使用xcode,请安装它(~12GB)

xcode-select --install

否则安装最新的命令行工具(~500MB)

更新:如果在安装循环中被击中

xcodebuild -runFirstLaunch

我也有同样的问题,更新后无法使用SVN,

万一执行xcode select--install无法解决问题,

你可能会看到,

svn:error:Xcode不再提供subversion命令行工具。

参考:https://developer.apple.com/documentation/macos_release_notes/macos_catalina_10_15_release_notes

尝试通过brew安装svn

brew install svn

这应该能让你继续。