xcode macOS 更新后 Git 不工作(xcrun:错误:无效的活动开发者路径 (/Library/Developer/CommandLineTools)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/52522565/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)
提问by dustbuster
I updated to macOS Mojave (this happens to Catalina update too).
我更新到 macOS Mojave(这也发生在 Catalina 更新上)。
This morning I navigated to my work's codebase in the Command Line on my MacBook pro, typed in "git status" in the repository and received the error:
今天早上,我在 MacBook Pro 的命令行中导航到我的工作代码库,在存储库中输入“git status”并收到错误:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
回答by dustbuster
The problem is that Xcode Command-line Tools needs to be updated.
问题是 Xcode 命令行工具需要更新。
Go back to your terminal and hit:
返回您的终端并点击:
xcode-select --install
You'll then receive:
然后您将收到:
xcode-select: note: install requested for command line developer tools
You will be prompted at this point in a window to update Xcode Command Line tools. (which may take a while)
此时将在窗口中提示您更新 Xcode 命令行工具。(这可能需要一段时间)
open a new terminal window and your development tools should be returned.
打开一个新的终端窗口,您的开发工具应该会返回。
Addition:With any major or semi-major update you'll need to update the command line tools in order to get them functioning properly again. Check Xcode with any update. This goes beyond Mojave...
添加:对于任何主要或半主要更新,您都需要更新命令行工具以使它们再次正常运行。检查 Xcode 是否有任何更新。这超越了莫哈韦沙漠......
After that restart your terminal
之后重启你的终端
回答by deef
I got some errors that the software was unavailable from the update server when trying
我在尝试时遇到一些错误,提示更新服务器上的软件不可用
xcode-select --install
xcode-select --install
What fixed it for me was going here https://developer.apple.com/download/more/and downloading Command Line Tools (macOS 10.14) for Xcode 10
and then installing it manually.
对我来说修复它的是去这里https://developer.apple.com/download/more/并下载Command Line Tools (macOS 10.14) for Xcode 10
然后手动安装它。
After that, the errors should be gone when you open up a new terminal.
之后,当您打开新终端时,错误应该消失了。
回答by H6.
For me xcode-select --reset
was the solution on Mojave.
对我来说xcode-select --reset
是莫哈韦沙漠的解决方案。
回答by Patrik Neperfekta
In addition to dustbuster's answer I needed to set path to the Xcode folder with this command:
除了dustbuster的回答之外,我还需要使用以下命令设置Xcode文件夹的路径:
sudo xcode-select -switch /Library/Developer/CommandLineTools
回答by Ryan Stewart
I've used xcode-select --install
given in the accepted answer in previous major releases.
我已经xcode-select --install
在以前的主要版本中接受的答案中使用了。
I've just upgraded to OS X 10.15 Catalina and run the Software Update tool from preferences again after the OS upgrade completed. The Xcode utilities update was available there, which also sorted the issue using git which had just output
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)
我刚刚升级到 OS X 10.15 Catalina,并在 OS 升级完成后再次从首选项运行软件更新工具。那里提供了 Xcode 实用程序更新,它还使用刚刚输出的 git 对问题进行了排序
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)
回答by briankip
For me what worked is the following:
对我来说,有效的是以下内容:
sudo xcode-select --reset
Then like in @High6's answer:
然后就像@High6 的回答:
sudo xcodebuild -license
This will reveal a license which I assume is some Xcode license. Scroll to the bottom using space(or the mouse) then tap agree
.
这将显示一个许可证,我认为它是一些 Xcode 许可证。使用space(或鼠标)滚动到底部,然后点击agree
。
This is what worked for me on MacOS Mojave v 10.14.
这就是在 MacOS Mojave v 10.14 上对我有用的方法。
回答by taha
回答by P. Hurme
I figured out the Xcode Command Line Tools part from the error message, but after running Xcode and getting the prompt to install the additional tools it did claim to install them, but still I got the same error after opening a new terminal.
我从错误消息中找出了 Xcode 命令行工具部分,但是在运行 Xcode 并提示安装其他工具后,它确实声称安装了它们,但是在打开新终端后我仍然遇到相同的错误。
So I did the xcode-select --install
manually and after that it worked for me.
所以我xcode-select --install
手动做了,然后它对我有用。
回答by Selim Reza
Open Terminal:
打开终端:
install XCode developer tools and fix the problem.
安装 XCode 开发人员工具并修复问题。
$ xcode-select --install
Reset the path to Xcode if you have several versions:
如果您有多个版本,请重置 Xcode 的路径:
$ xcode-select --switch /Applications/Xcode.app
$ xcode-select --switch /Library/Developer/CommandLineTools
回答by Ali ?zy?ld?r?m
If you have Xcode downloaded manually (i.e. not from the App Store) or don't have Xcode at all:
如果您手动下载了 Xcode(即不是从 App Store 下载的)或根本没有 Xcode:
sudo rm -rf /Library/Developer/CommandLineTools
- Go to https://developer.apple.com/download/more/to download Command Line Tools (macOS 10.14) for Xcode 10
- Setup Command Line Tools
sudo rm -rf /Library/Developer/CommandLineTools
- 前往https://developer.apple.com/download/more/下载适用于 Xcode 10 的命令行工具 (macOS 10.14)
- 设置命令行工具
If you have Xcode installed from the App Store:
如果您从 App Store 安装了 Xcode:
xcode-select --install
xcode-select --install