Xcode-select活动开发者目录错误

985
在运行需要 "node-gyp" 的 "npm install" 过程中,遇到了以下错误...但是任何需要 "xcode-select" 的东西都可能会引发此错误。 问题是什么?

3
一种直接有效的替代方法就是卸载它,然后重新安装。在所有的答案中,这是唯一对我起作用的。 - qodeninja
@qodeninja 重新安装对我没有起作用。 - user5306470
请确保Xcode应用程序位于/Applications目录中,并且它对我有效。 - undefined
30个回答

1

1

对于那些使用较新版本的Xcode(我正在使用14.3),您需要安装命令行工具。

我建议两种方法。

  1. 在终端上运行以下命令:

    xcodebuild -runFirstLaunch xcode-select --install

  2. 或从this link下载可安装的DMG文件(Xcode 14.3的命令行工具)并进行安装。

当我尝试在macOS 13.3上安装brew时,我遇到了这个问题。


1
为了提供背景,今天是2019年1月28日。
在我的Mac上,我做了两件事来解决这个问题:
  1. 在终端中运行以下命令:
    sudo xcode-select --install

  2. 重新启动你的Mac。

在我重新启动计算机之前,这个问题一直出现在我的Android Studio中。重启后,一切正常。还要注意的是,我没有执行任何像其他人所做的--switch命令。希望这可以帮助你。

0

以上方法都对我无效。我最初是单独安装了命令行工具,然后再安装了整个Xcode。对我有效的方法是按照这里所示的步骤卸载命令行工具。然后,当我再次尝试运行xcode-select时,系统会要求我重新安装它们。

*顺便说一下,我找到这个帖子的原因是因为我使用macports安装了一些库(特别是gcc),可能是使用旧版的命令行工具,然后在开发过程中安装了完整的Xcode。所以,对于我的情况,我必须在删除独立的命令行工具、重新安装它们、重新安装gcc之后重新安装macports,然后我的编译才能正常工作。


0

只需要两个步骤,完整的XCode.app不是必需的

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

此时会弹出“安装软件”对话框:

enter image description here

就是这样!


0

就我的情况而言,

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer 

不能工作是因为我的Xcode有一些特殊的名称。例如)Xcode_11.2.0_beta_2_stackoverflow.app

cd /applications
ls

然后我找到了我的Xcode名称,然后用它替换掉

sudo xcode-select -s /Applications/{myXcodeName}.app/Contents/Developer 

这对我有用。


0

以上解决方案都没能帮助我。我正在处理一个项目,并且我在计算机上全局安装了最新版本的NodeJs(v14.x)。

对我来说,任何高于10.1.x的node版本都无法工作,当我测试时收到了与上述相同的错误。

解决方案

  • 我安装了"n", 它是类似nvm的NodeJs版本管理器
  • 我将我的NodeJs版本降级到9.x
  • npm install 现在可以运行。

现在我需要更新我的版本,或者在我的package.json文件中指定我的node版本


0
我所做的一切都是在终端上运行以下命令:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

0
我使用的简单解决方法是将Xcode.app从当前位置(在我的情况下是下载文件夹)拖放到应用程序中。

0
sudo xcode-select -s /Applications/Xcode 10.app/Contents/Developer

languoguangs-iMac:/ languoguang$ sudo xcode-select -s /Applications/Xcode 10.app/Contents/Developer
xcode-select: error: invalid argument '10.app/Contents/Developer'
Usage: xcode-select [options]

Print or change the path to the active developer directory. This directory
controls which tools are used for the Xcode command line tools (for example, 
xcodebuild) as well as the BSD development commands (such as cc and make).

Options:
  -h, --help                  print this help message and exit
  -p, --print-path            print the path of the active developer directory
  -s <path>, --switch <path>  set the path for the active developer directory
  --install                   open a dialog for installation of the command line developer tools
  -v, --version               print the xcode-select version
  -r, --reset                 reset to the default command line tools path
languoguangs-iMac:/ languoguang$ sudo xcode-select -s "/Applications/Xcode 10.app/Contents/Developer"

因为我的应用程序中的Xcode名称是“Xcode 10”,

sudo xcode-select -s "/Applications/Xcode 10.app/Contents/Developer"

运作正常。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接