尝试在macOS上安装自制软件时发生xcode选择错误

尝试在macOS上安装自制软件时发生xcode选择错误,macos,installation,homebrew,Macos,Installation,Homebrew,尝试在macOS Sierra上安装自制软件时: xcode-select: error: invalid developer directory '/Library/Developer/CommandLineTools' Failed during: /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools 不幸的是,我不能发表评论,所以我将把它作为一个答案发布: 如果要为自制选择正确的

尝试在macOS Sierra上安装自制软件时:

xcode-select: error: invalid developer directory '/Library/Developer/CommandLineTools' 
Failed during: /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools

不幸的是,我不能发表评论,所以我将把它作为一个答案发布:

如果要为自制选择正确的Xcode版本,请尝试以下操作:

对于Xcode版本:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
对于Xcode测试版:

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

我通过安装最新版本的Xcode解决了这个错误。

我也遇到了同样的错误,我唯一能解决这个问题的方法就是直接从developer.apple.com下载Xcode命令行工具,手动安装它们。安装后,brew安装工作正常。

处理此问题的最简单方法是运行:
xcode选择--install

是的,我已经通过使用以下步骤解决了这个错误

  • 在终端写入命令::xcode中选择--install
  • 完成第一步后,您将得到一个弹出窗口,因此单击安装

  • 我已经在macOS catalina中解决了相同的问题,只是更新macOS


    为了更新macOS,我尝试手动安装命令行工具,但安装时命令行工具失败。重新安装XCode毫无帮助

    因此,我尝试使用下面的命令帮助我解决Big Sur 11.2.1(20D74)上的此错误

    sudo rm-rf/Library/Developer/CommandLineTools

    sudoxcode选择--安装

    /bin/bash-c“$(curl-fsSL)”


    那个目录存在吗?因此,该计划不应该再失败了。