xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
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 How can I ignore it, when I want to run cordova emulate ios and it does not work? Because it throws that error.
@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.
@jfmercer answer works for me!
you can always do a xcode-select -r if you already have command line tools or Xcode already installed.
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?
None of the other solutions worked for me, however deleting my package-lock.json and reinstalling npm install allowed it to rebuild correctly.
sudo xcode-select -s ... needs to be followed by: sudo xcodebuild license before you 'make' or 'configure' again.
Use command to get $path = xcode-select -print-path then use command sudo xcode-select -switch $path
Try sudo xcode-select -r. This command worked for me.
Used command 'sudo xcodebuild -license accept' to accept the license.
@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
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.
It works with me on macOS High Sierra, thanks a lot!
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.
If you only have Xcode-beta installed, install the release version of Xcode too and it should work
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
@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 This worked ☝️
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 This worked ☝️