node-gyp icon indicating copy to clipboard operation
node-gyp copied to clipboard

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

Open davis opened this issue 11 years ago • 150 comments

EDITED FOR PEOPLE JUST GETTING HERE

See https://github.com/nodejs/node-gyp/issues/569#issuecomment-255589932 and https://github.com/nodejs/node-gyp/issues/569#issuecomment-259421050, the warning can just be ignored. Command Line Tools works fine, you do not need the full Xcode.

See https://github.com/nodejs/node-gyp/blob/master/macOS_Catalina.md, here and here for more info.

Fix:

xcode-select --install # Install Command Line Tools if you haven't already.
sudo xcode-select --switch /Library/Developer/CommandLineTools # Enable command line tools

then just ignore the warning.

Alternatively if you want you can use the full Xcode.app (if you have it installed) with:

# Change the path if you installed Xcode somewhere else.
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

If your install is failing

There will be other errors nearer the end, almost certainly issues with the module you're trying to install or a dependency. Please report the error to that project.

If that doesn't work

Are you seeing this when you run node-gyp rebuild or npm install? If not then it's nothing to do with node-gyp, raise a bug with the project you're using.

davis avatar Jan 28 '15 02:01 davis

@davis How can I ignore it, when I want to run cordova emulate ios and it does not work? Because it throws that error.

aleksander351 avatar Nov 17 '17 15:11 aleksander351

@aleksander351 you haven't installed Xcode, which is a requirement for cordova (see their docs: http://cordova.apache.org/docs/en/dev/guide/platforms/ios/index.html#installing-the-requirements).

Nothing to do with node-gyp.

gibfahn avatar Nov 17 '17 17:11 gibfahn

@jfmercer answer works for me!

HanSJin avatar Dec 04 '17 05:12 HanSJin

you can always do a xcode-select -r if you already have command line tools or Xcode already installed.

thehashrocket avatar Jan 02 '18 21:01 thehashrocket

It seems like xcodebuild (and consequently the full ~5GB Xcode install) is still needed to accept the Xcode license even if you just want the command line tools?

haribharadwaj avatar Jan 03 '18 16:01 haribharadwaj

None of the other solutions worked for me, however deleting my package-lock.json and reinstalling npm install allowed it to rebuild correctly.

tmburnell avatar Jan 15 '18 19:01 tmburnell

sudo xcode-select -s ... needs to be followed by: sudo xcodebuild license before you 'make' or 'configure' again.

tngn avatar Mar 15 '18 14:03 tngn

Use command to get $path = xcode-select -print-path then use command sudo xcode-select -switch $path

deora-deepak avatar Jun 14 '18 11:06 deora-deepak

Try sudo xcode-select -r. This command worked for me.

sesn avatar Jun 15 '18 18:06 sesn

Used command 'sudo xcodebuild -license accept' to accept the license.

patrickcat avatar Jun 19 '18 06:06 patrickcat

@patrickcat when I try to run sudo xcodebuild -license accept, I get the following:

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

jonesnc avatar Jun 27 '18 15:06 jonesnc

I know this is not the best place for it; but this is the top result on Google, so hopefully this helps other people landing here due to a yarn installor npm install error:

For me, on OSX 10.13.6 High Sierra, node 10.6.0 and npm 6.1.0, this was due to the slightly outdated 3.6.2 version of node-gyp shipped with npm.

TL;DR, I fixed it with

cd /usr/local/Cellar/node/10.6.0/libexec/lib/node_modules/npm/ && npm update node-gyp

Root cause seems to be XcodeVersion() throwing up:

gyp info using [email protected]
gyp info using [email protected] | darwin | x64

[...]

Traceback (most recent call last):

  File "/usr/local/Cellar/node/10.6.0/libexec/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 16, in <module>

[...]

  File "/usr/local/Cellar/node/10.6.0/libexec/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 118, in GetXcodeArchsDefault
    xcode_version, _ = XcodeVersion()

  File "/usr/local/Cellar/node/10.6.0/libexec/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 1265, in XcodeVersion
    version = re.match(r'(\d\.\d\.?\d*)', version).groups()[0]

AttributeError: 'NoneType' object has no attribute 'groups'

As logged above, this happens with node-gyp v3.6.2, but the above regex bug was fixed in v3.6.3:

2  gyp/pylib/gyp/xcode_emulation.py
@@ -1262,7 +1262,7 @@ def XcodeVersion():
   except:
     version = CLTVersion()
     if version:
-      version = re.match(r'(\d\.\d\.?\d*)', version).groups()[0]
+      version = re.match(r'(\d+\.\d+\.?\d*)', version).groups()[0]
     else:
       raise GypError("No Xcode or CLT version detected!")
     # The CLT has no build information, so we return an empty string.

I double-checked that my node and npm were the latest version, but sadly as it turns out npm 6.1.0 still tracks node-gyp 3.6.2.


Therefore, I artifically upgraded

/usr/local/Cellar/node/10.6.0/libexec/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js -v
# v3.6.2

By running

cd /usr/local/Cellar/node/10.6.0/libexec/lib/node_modules/npm/
npm update node-gyp

To get to

/usr/local/Cellar/node/10.6.0/libexec/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js -v
# v3.7.0

At which point I could run my yarn install again without issue.

npny avatar Jul 11 '18 11:07 npny

It works with me on macOS High Sierra, thanks a lot!

LucianLiu6 avatar Jul 13 '18 07:07 LucianLiu6

For me, it was because the JRE folder was not existing for some reason.

I had two JDK installations

  • jdk1.8.0_*
  • jdk_10.*

Somehow, node-gyp rebuild was attempting to use jdk_10.* which had no jre folder.

Fix

Copying the JRE folder from jdk1.8.0_* to jdk_10.*/Contents/Home fixed it for me.

Ruqoyah avatar Jul 18 '18 12:07 Ruqoyah

If you only have Xcode-beta installed, install the release version of Xcode too and it should work

gregoryyoung2 avatar Jul 23 '18 14:07 gregoryyoung2

I already have Xcode so I removed CommandLineTools and linked Xcode. Thoughts?

$ sudo rm -rf /Library/Developer/CommandLineTools
$ sudo xcode-select --switch /Applications/Xcode.app

JBallin avatar Jul 25 '18 04:07 JBallin

@npny's digging is right on the money. Here's the relevant node-gyp issue.

Xcode Command Line Tools v10.0 (mine landed on my box Sep 17) appears to be incompatible with [email protected], used by [email protected]. I bumped to [email protected] (latest LTS), which pulls node-gyp up to 3.8.0.

npm rebuild <your-busted-package-here> works again \o/

ericsoco avatar Sep 20 '18 18:09 ericsoco

@ericsoco This worked ☝️

gabitoesmiapodo avatar Sep 20 '18 19:09 gabitoesmiapodo

After the latest High Sierra Command Line Tools update for Xcode 10.0, I needed to uninstall my command line tool: $ rm -rf /Library/Developer/CommandLineTools

Then reinstall them using the commands at the top of this forum. Researched for hours and that's all I could find that would fix my issue. I also don't have Xcode installed.

skylarweaver avatar Sep 24 '18 14:09 skylarweaver

@skylarweaver This worked ☝️

banacorn avatar Sep 25 '18 02:09 banacorn