我正在尝试通过命令行更新Xcode。最初,我尝试运行:
xcode-select --install
导致产生了这条消息:
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
那么问题仍然是,有没有一种方法可以通过命令行更新Xcode?
我正在尝试通过命令行更新Xcode。最初,我尝试运行:
xcode-select --install
导致产生了这条消息:
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
那么问题仍然是,有没有一种方法可以通过命令行更新Xcode?
xcode-select --install
。因此,你得到的错误消息是 - 工具已经安装。softwareupdate command [args ...]
。你可以使用softwareupdate --list
查看可用内容,然后使用softwareupdate --install -a
安装所有更新或softwareupdate --install <product name>
仅安装Xcode更新(如果有可用的)。你可以从列表命令中获取名称。softwareupdate
工具的man页面。
2019年更新
许多用户遇到了问题,softwareupdate --install -a
实际上不能更新到最新版本的Xcode。造成这种情况的原因很可能是有待处理的macOS更新(正如@brianlmerritt在下面指出的那样)。在大多数情况下,先更新macOS就可以解决问题,并允许更新Xcode。
更新Xcode命令行工具
许多用户尝试更新Xcode命令行工具而来到了这个答案。最简单的方法是删除旧版本的工具,然后安装新版本。sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
一个弹出窗口将出现并引导您完成其余的过程。
softwareupdate -i -r
只安装了“[推荐]”安装包,即命令行工具。它下载了两次,安装了一次,然后完成了安装。
由于它没有解决问题,我重新运行了 softwareupdate --list
命令,但是推荐内容仍然存在。在应用商店中,软件更新选项消失然后又重新出现。当我尝试通过应用商店进行更新时,要求我接受用户条款。接受后,更新好像成功了。
再次运行 softwareupdate --list
命令,发现它仍被推荐更新。 - GMarxsudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
请注意,此处仅为翻译,不提供任何解释或其他内容。 - Adiaos我曾经遇到相同的问题,通过以下步骤解决:
$ sudo rm -rf /Library/Developer/CommandLineTools
)$ xcode-select --install
)。完成以上步骤后,您将看到一个弹出框,提示安装新版本的工具。
/Library/Developer/CommandLineTools
目录。然而,新目录也已经过时(来自Xcode 7.3而不是当前的9.4),所以它没有解决我的问题。最终我在https://developer.apple.com/download/more/上搜索开发者工具,并从那里下载了`Command_Line_Tools_macOS_10.13_for_Xcode_9.4.1`。 - jbylersudo rm -rf /Library/Developer/CommandLineTools
。 - Georgesudo rm -rf $(xcode-select -print-path)
命令,因此您不需要删除所有命令行工具,因为这似乎有些过度。 - mtx当我卸载完整版Xcode以重新安装CLI版本时,我遇到了相同的问题。我的解决方法是:
sudo xcode-select -s /Library/Developer/CommandLineTools
xcode-select --install
),输入以下命令:sudo xcode-select --switch /Library/Developer/CommandLineTools/
现在,您应该能够运行git:
10:29 $ git --version
git version 2.17.2 (Apple Git-113)
pyenv install
中遇到的错误(configure: error: C compiler cannot create executables
)。 - RCB删除Xcode后,我遇到了这个错误。通过使用sudo xcode-select -r
重新设置命令行工具路径来解决它。
之前:
navin@Radiant ~$ /usr/bin/clang
xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist
Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.
See `man xcode-select` for more details.
navin@Radiant ~$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
之后:
navin@Radiant ~$ /usr/bin/clang
clang: error: no input files
只需输入命令
cd /Library/Developer/CommandLineTools/Packages/;
open macOS_SDK_headers_for_macOS_10.14.pkg
我不确定为什么这对我来说如此棘手。
sudo xcode-select --install
对我来说没有任何帮助。
softwareupdate --all --install --force
对我没有任何帮助。
我必须按以下顺序执行任务。
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
这安装了新版本的Xcode,但不是最新版本。
然后我进行了以下操作:
softwareupdate --all --install --force
他们进行了完全的更新。
$ sudo rm -rf /Library/Developer/CommandLineTools
$ xcode-select --install
我也遇到了同样的问题,通过使用以下命令来解决它。
sudo xcode-select -s /Library/Developer/CommandLineTools
运行上述命令后,然后运行 xcode-select -p 命令,结果显示如下。
/Library/Developer/CommandLineTools