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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:34:07  来源:igfitidea点击:

Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)

xcodegitmacoscommand-lineterminal

提问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 10and 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 --resetwas 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 --installgiven 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

in my case it wasn't checked in xcode After installation process ,

在我的情况下,它没有在 xcode 中检查安装过程后,

you can do that as following : xcode -> Preferences and tap Locations then select , as the followng image

你可以这样做:xcode -> Preferences 并点击 Locations 然后选择,如下图

enter image description here

在此处输入图片说明

回答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 --installmanually 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:

  1. sudo rm -rf /Library/Developer/CommandLineTools
  2. Go to https://developer.apple.com/download/more/to download Command Line Tools (macOS 10.14) for Xcode 10
  3. Setup Command Line Tools
  1. sudo rm -rf /Library/Developer/CommandLineTools
  2. 前往https://developer.apple.com/download/more/下载适用于 Xcode 10 的命令行工具 (macOS 10.14)
  3. 设置命令行工具

If you have Xcode installed from the App Store:

如果您从 App Store 安装了 Xcode:

  1. xcode-select --install
  1. xcode-select --install