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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17980759/
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-09 04:52:02  来源:igfitidea点击:

xcode-select active developer directory error

xcodemacosnpmnpm-installcommand-line-tool

提问by tjmehta

Saw the following error when running an npm installwhich required node-gyp... but could be triggered by anything which requires xcode-select.

运行npm installwhich required node-gyp...时看到以下错误,但任何需要xcode-select.

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

xcode-select: 错误:工具“xcodebuild”需要 Xcode,但活动开发者目录“/Library/Developer/CommandLineTools”是命令行工具实例

What is the problem?

问题是什么?

回答by tjmehta

This problem happens when xcode-selectdeveloper directory was pointing to /Library/Developer/CommandLineTools, when a full regular Xcode was required (happens when CommandLineTools are installed after Xcode)

xcode-select开发者目录指向/Library/Developer/CommandLineTools时,需要完整的常规 Xcode 时会发生此问题(在 Xcode 之后安装 CommandLineTools 时发生)

Solution:

解决方案:

  1. Install Xcode (get it from https://appstore.com/mac/apple/xcode) if you don't have it yet.
  2. Accept the Terms and Conditions.
  3. Ensure Xcode app is in the /Applicationsdirectory (NOT /Users/{user}/Applications).
  4. Point xcode-selectto the Xcode app Developer directory using the following command:
    sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
  1. 如果您还没有安装 Xcode(从https://appstore.com/mac/apple/xcode获取 )。
  2. 接受条款和条件。
  3. 确保 Xcode 应用程序在/Applications目录中 (NOT /Users/{user}/Applications)。
  4. xcode-select使用以下命令指向Xcode 应用程序开发者目录:
    sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

Note: Make sure your Xcode app path is correct.

注意:确保您的 Xcode 应用程序路径正确。

  • Xcode: /Applications/Xcode.app/Contents/Developer
  • Xcode-beta: /Applications/Xcode-beta.app/Contents/Developer
  • 代码: /Applications/Xcode.app/Contents/Developer
  • Xcode-测试版: /Applications/Xcode-beta.app/Contents/Developer

回答by Indamix

Other solution for those who don't want to install Xcode:

对于不想安装 Xcode 的人的其他解决方案:

  1. Install Command Line Tools (if you haven't already):

    xcode-select --install

  2. Change the active directory:

    sudo xcode-select -switch /Library/Developer/CommandLineTools

  1. 安装命令行工具(如果您还没有):

    xcode-select --install

  2. 更改活动目录:

    sudo xcode-select -switch /Library/Developer/CommandLineTools

This worked for me (git).

这对我有用(git)。

回答by jay.tech66

I was having an issue while trying to install packages using npm. I got the error: "sudo xcode-select -s /Applications//Xcode.app/Contents/Developer/"

我在尝试使用 npm 安装软件包时遇到问题。我收到错误:“sudo xcode-select -s /Applications//Xcode.app/Contents/Developer/”

To fix this

要解决这个问题

  • I opened Xcode.
  • Preferences
  • Locations
  • Selected the Command Lin Tools: Xcode 6.1.1
  • 我打开了Xcode。
  • 喜好
  • 地点
  • 选择命令行工具:Xcode 6.1.1

Now when installing packages with npm I no longer get errors.

现在,当使用 npm 安装软件包时,我不再出现错误。

回答by FranklinA

Xcode->Preferences->Locations->command line tools

Xcode->首选项->位置->命令行工具

screenshot

截屏

Select the option: Xcode 8.x

选择选项:Xcode 8.x

回答by chunkyguy

Simply run sudo xcode-select -rwhich should automatically reset the path.

只需运行sudo xcode-select -r它应该会自动重置路径。

 -r, --reset
              Unsets any user-specified developer directory, so that the developer directory will be found via the default search mechanism. This command must  be
              run with superuser permissions (see sudo(8)), and will affect all users on the system.

回答by Andrey Deineko

Just in case you're using xcode beta:

以防万一您使用的是 xcode beta:

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

回答by Hamoon Jamshidi Meydandar

I had to run this first

我必须先运行这个

sudo xcode-select --reset

then

然后

sudo xcode-select -switch /Library/Developer/CommandLineTools

and then it worked.

然后它起作用了。

回答by Rahul Shenoy

  1. Download Xcode from App Store.

  2. Go to Xcode preferences/Locations/CommandlineTools

    You just have to set it to the Xcode version. It automatically points to '/Application/Xcode.app'

  1. 从 App Store 下载 Xcode。

  2. 转到 Xcode 首选项/位置/CommandlineTools

    您只需将其设置为 Xcode 版本即可。它自动指向'/Application/Xcode.app'

回答by javamonk

Without Xcode: create file /usr/local/bin/xcodebuildwith content to cheat XcodeSelect

没有 Xcode:创建/usr/local/bin/xcodebuild包含内容的文件来欺骗 XcodeSelect

  #!/bin/bash
  exit 0

chmod +x /usr/local/bin/xcodebuild

chmod +x /usr/local/bin/xcodebuild

回答by sandeepkohli

Install Xcode from App Store. After installing run xcodebuild with root privileges i.e. sudo xcodebuildand accept the language. After this npm install bcryptworked like a charm!

从 App Store 安装 Xcode。安装后以 root 权限运行 xcodebuildsudo xcodebuild并接受语言。在这之后npm install bcrypt就像一个魅力!