可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
Saw the following error when running an npm install which required node-gyp... but could be triggered by anything which requires xcode-select.
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
What is the problem?
回答1:
This problem happens when xcode-select developer directory was pointing to /Library/Developer/CommandLineTools, when a full regular XCode was required (happens when CLT are installed after XCode)
Solution:
- Install Xcode (get it from https://developer.apple.com/xcode/) if you don't have it yet.
- Accept the Terms and Conditions.
- Ensure Xcode app is in the
/Applications directory (NOT /Users/{user}/Applications). - Point
xcode-select to the Xcode app Developer directory using the following command:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Note: Make sure your Xcode app path is correct.
- Xcode:
/Applications/Xcode.app/Contents/Developer - Xcode-beta:
/Applications/Xcode-beta.app/Contents/Developer
回答2:
Other solution for those who don't want to install 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).
回答3:
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/"
To fix this
- I opened Xcode.
- Preferences
- Locations
- Selected the Command Lin Tools: Xcode 6.1.1
Now when installing packages with npm I no longer get errors.
回答4:
Xcode->Preferences->Locations->command line tools
Select the option: Xcode 8.x
回答5:
Just in case you're using xcode beta:
sudo xcode-select -s /Applications/Xcode-Beta.app/Contents/Developer
回答6:
Install Xcode from App Store. After installing run xcodebuild with root privileges i.e. sudo xcodebuild and accept the language. After this npm install bcrypt worked like a charm!
回答7:
Simply run sudo xcode-select -r which should automatically reset the path.
-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.
回答8:
Without Xcode: create file /usr/local/bin/xcodebuild with content to cheat XcodeSelect
#!/bin/bash exit 0
chmod +x /usr/local/bin/xcodebuild
回答9:
XCode2: sudo xcode-select -s /Applications/Xcode\ 2.app/Contents/Developer
Pay attention to the "\" to escape the space
回答10:
I had two instance of Xcode installed xcode.app and xcode-beta.app When I tried to create a build with netbeans it showed me the error "supported version of xcode and command line tools not found netbeans"
I followed the following steps:
- "xcode-select --print-path" is equal to "/Applications/Xcode.app/Contents/Developer"
- "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform" exists
- "xcodebuild -version" starts with "Xcode"
after 1 I found that it is pointing me to xcode-beta.app
so here is the solution which worked like a charm:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
回答11:
Download Xcode from App Store.
Go to Xcode preferences/Locations/CommandlineTools
You just have to set it to the Xcode version. It automatically points to '/Application/Xcode.app'