欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

Fix Git not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) 修复 macOS 更新后 Git 无法正常工作的问题(xcrun:错误:无效的活动开发人员路径 (/Library/Developer/CommandLineTools) 有大用 有大大用

Fix Git not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)
修复 macOS 更新后 Git 无法正常工作的问题(xcrun:错误:无效的活动开发人员路径 (/Library/Developer/CommandLineTools)

Jul 19, 2021 - 6 Comments
2021 年 7 月 19 日 - 6 评论

Fix xcrun error invalid developer path at Mac Terminal


Some Mac Terminal users may discover git, pip, HomeBrew, and other command line tools may fail or not work as intended with an error message stating “xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)”. Sometimes these command line tools stop working after a macOS system software update, but they worked previously.
某些 Mac 终端用户可能会发现 git、pip、HomeBrew 和其他命令行工具可能会失败或无法按预期工作,并显示一条错误消息,指出“xcrun:错误:无效的活动开发人员路径 (/Library/Developer/CommandLineTools)”。有时,这些命令行工具在 macOS 系统软件更新后停止工作,但它们以前可以工作。

Fortunately it’s easy to fix the “xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)” error message, and get git, pip, Homebrew, or whatever other command line tool that failed, to start working again.
幸运的是,很容易修复“xcrun:错误:无效的活动开发人员路径(/Library/Developer/CommandLineTools)”错误消息,并获取git,pip,Homebrew或任何其他失败的命令行工具,以重新开始工作。

For what it’s worth, the full error message is:
值得一提的是,完整的错误消息是:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
xcrun:错误:活动开发人员路径无效 (/Library/Developer/CommandLineTools),缺少 xcrun:/Library/Developer/CommandLineTools/usr/bin/xcrun

Fix “xcrun: error: invalid active developer path” Error in Terminal on MacOS
修复 MacOS 终端中的“xcrun:错误:无效的活动开发人员路径”错误

The solution, as you may have guessed from the error message itself, is to reinstall or install Command Line Tools. Yes, even if you already have command line tools installed, you should reinstall it to resolve the error message, particularly if you are only experiencing the error after a system software update (eg, from Mojave to Monterey).
正如您可能已经从错误消息本身中猜到的那样,解决方案是重新安装或安装 命令行工具 . 是的,即使您已经安装了命令行工具,也应该重新安装它以解决错误消息,特别是如果您仅在系统软件更新后遇到错误(例如,从莫哈韦到蒙特雷)。

Installing/reinstalling CLT can be done from the command line by issuing the following command string in Terminal:
通过在终端中发出以下命令字符串,可以从命令行安装/重新安装 CLT:

xcode-select --install

Hitting return will cause a pop-up to appear with a progress indicator on the download for Command Line Tools.
按回车键将导致在命令行工具的下载中出现一个弹出窗口,其中包含进度指示器。

Once the installation of Command Line Tools has completed, you should reboot the Mac (sometimes simply refreshing, relaunching Terminal, or opening a new Terminal may resolve the ‘xcrun error invalid active developer path’ message too, but a reboot is recommended).
命令行工具安装完成后,您应该重新启动 Mac(有时只需刷新、重新启动终端或打开新终端也可以解决“xcrun 错误无效的活动开发人员路径”消息,但建议重新启动)。

If you are using Homebrew, you should also be sure to update Homebrew after you have (re)installed Command Line Tools.
如果您使用的是 Homebrew,您还应该确保在(重新)安装命令行工具后更新 Homebrew。

Still seeing xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)?
仍然看到 xcrun:错误:无效的活动开发人员路径 (/Library/Developer/CommandLineTools)?

If you installed or reinstalled command line tools through Terminal, rebooted the Mac, and you’re still getting the error, you can also try to manually install Command Line Tools by using a DMG file directly from Apple.
如果您通过终端安装或重新安装了命令行工具,重新启动了 Mac,但仍然收到错误,您也可以尝试使用直接来自 Apple 的 DMG 文件手动安装命令行工具。

You will need an Apple ID to access the download, then just head to developer.apple.com and download Command Line Tools for Xcode (latest version) and install it manually.
您需要一个 Apple ID 才能访问下载,然后只需前往 developer.apple.com 并下载 Command Line Tools for Xcode(最新版本)并手动安装即可。

Again, Homebrew users will want to update Homebrew. You should not have to install Homebrew again or remove it and then reinstall it, a simple update should do the trick.
同样,Homebrew 用户将希望更新 Homebrew。您不必再次安装 Homebrew 或将其删除然后重新安装,简单的更新应该可以解决问题。

Git is not working after updating MacOS because of xcrun error?
由于xcrun错误,更新MacOS后Git无法正常工作?

If you discover that Git is no longer working after installing a MacOS system software update, first try to install xcode Command Line Tools:
如果您在安装 MacOS 系统软件更新后发现 Git 不再工作,请先尝试安装 xcode 命令行工具:

Check System Settings / Preferences > General > Software Update to see if any updates to Command Line Tools are shown.
检查“系统设置”/首选项>“常规>软件更新”,查看是否显示命令行工具的任何更新。

You can also reinstall Xcode Command Line Tools through Terminal:
您也可以通过终端重新安装 Xcode 命令行工具:

xcode-select --install

Command Line Tools often needs to update after installing a MacOS system update.
命令行工具通常需要在安装 MacOS 系统更新后进行更新。

You also may need to agree to the Xcode license again after installing an update before it will work again.
安装更新后,您可能还需要再次同意 Xcode 许可证,然后它才能再次运行。

sudo xcodebuild --license

Did this work to resolve your issues with git, pip, Homebrew, or whatever was triggering the xcrun error message at the command line on your Mac? Did you find another solution? Share your thoughts and experiences in the comments.
这是否可以解决您在 Mac 上的命令行中触发 xcrun 错误消息的 git、pip、Homebrew 或任何问题?你找到其他解决方案了吗?在评论中分享您的想法和经验。


来自  https://osxdaily.com/2021/07/19/fix-xcrun-error-invalid-active-developer-path-error-terminal-mac/#:~:text=Fix%20%E2%80%9Cxcrun%3A%20error%3A%20invalid%20active%20developer%20path%E2%80%9D%20Error,is%20to%20reinstall%20or%20install%20Command%20Line%20Tools.


普通分类: