本文翻译自:xcode-select active developer directory error
Saw the following error when running an npm install
which required node-gyp
... but could be triggered by anything which requires xcode-select
. 运行npm install
,需要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? 问题是什么?
#1楼
参考:https://stackoom.com/question/1DRcF/xcode选择活动的开发人员目录错误
#2楼
This problem happens when xcode-select
developer 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之后安装/Library/Developer/CommandLineTools
时发生),就会发生此问题。
Solution: 解:
- Install Xcode (get it from https://developer.apple.com/xcode/ ) if you don't have it yet. 如果还没有, 请安装Xcode(可从https://developer.apple.com/xcode/获得)。
- Accept the Terms and Conditions. 接受条款和条件。
- Ensure Xcode app is in the
/Applications
directory (NOT/Users/{user}/Applications
). 确保Xcode应用程序位于/Applications
目录中(不是/Users/{user}/Applications
)。 - Point
xcode-select
to the Xcode app Developer directory using the following command: 使用以下命令将xcode-select
指向Xcode app Developer目录: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:/Applications/Xcode.app/Contents/Developer
- Xcode-beta:
/Applications/Xcode-beta.app/Contents/Developer
Xcode-beta:/Applications/Xcode-beta.app/Contents/Developer
#3楼
Other solution for those who don't want to install Xcode: 对于那些不想安装Xcode的人的其他解决方案:
Install Command Line Tools (if you haven't already): 安装命令行工具(如果尚未安装):
xcode-select --install
Change the active directory: 更改活动目录:
sudo xcode-select -switch /Library/Developer/CommandLineTools
This worked for me (git). 这对我有用(git)。
#4楼
Install Xcode from App Store. 从App Store安装Xcode。 After installing run xcodebuild with root privileges ie sudo xcodebuild
and accept the language. 安装后,以root权限(即sudo xcodebuild
运行xcodebuild并接受该语言。 After this npm install bcrypt
worked like a charm! 在此npm install bcrypt
就像一个魅力一样npm install bcrypt
了作用!
#5楼
I was having an issue while trying to install packages using npm. 尝试使用npm安装软件包时遇到问题。 I got the error: "sudo xcode-select -s /Applications//Xcode.app/Contents/Developer/" 我收到错误:“ sudo xcode-select -s /Applications//Xcode.app/Contents/Developer/”
To fix this 要解决这个问题
- I opened Xcode. 我打开了Xcode。
- Preferences 首选项
- Locations 地点
- Selected the Command Lin Tools: Xcode 6.1.1 选择了Command Lin工具:Xcode 6.1.1
Now when installing packages with npm I no longer get errors. 现在,当使用npm安装软件包时,不再出现错误。
#6楼
Without Xcode: create file /usr/local/bin/xcodebuild
with content to cheat XcodeSelect 如果没有Xcode:创建文件/usr/local/bin/xcodebuild
并包含内容以欺骗XcodeSelect
#!/bin/bash
exit 0
chmod +x /usr/local/bin/xcodebuild