xcode-select active developer directory error

2019-01-02 21:17发布

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?

13条回答
姐就是有狂的资本
2楼-- · 2019-01-02 21:58

Just in case you're using xcode beta:

sudo xcode-select -s /Applications/Xcode-Beta.app/Contents/Developer
查看更多
神经病院院长
3楼-- · 2019-01-02 21:59

I was having the same problem in high sierra. running the following command solved it npm explore npm -g -- npm install node-gyp@latest

查看更多
成全新的幸福
4楼-- · 2019-01-02 22:01

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:

  1. Install Xcode (get it from https://developer.apple.com/xcode/) if you don't have it yet.
  2. Accept the Terms and Conditions.
  3. Ensure Xcode app is in the /Applications directory (NOT /Users/{user}/Applications).
  4. 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
查看更多
对你真心纯属浪费
5楼-- · 2019-01-02 22:05
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"

because my Xcode name in Application is "Xcode 10",

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

works.

查看更多
劳资没心,怎么记你
6楼-- · 2019-01-02 22:07

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

screenshot

Select the option: Xcode 8.x

查看更多
SAY GOODBYE
7楼-- · 2019-01-02 22:09

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.
查看更多
登录 后发表回答