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

I'm getting this error on Mojave with node 13.1.0, npm 6.12.1 and yarn 1.19.1

$ yarn
yarn install v1.19.1
[1/5] 🔍  Validating package.json...
[2/5] 🔍  Resolving packages...
[3/5] 🚚  Fetching packages...
[4/5] 🔗  Linking dependencies...
[5/5] 🔨  Building fresh packages...
[1/7] ⠈ node-lmdb
[-/7] ⠈ waiting...
[-/7] ⠈ waiting...
[-/7] ⠈ waiting...
error /Users/myuser/Desktop/core-js/node_modules/node-lmdb: Command failed.
Exit code: 1
Command: prebuild-install || node-gyp rebuild
Arguments: 
Directory: /Users/myuser/Desktop/core-js/node_modules/node-lmdb
Output:
prebuild-install WARN install No prebuilt binaries found (target=13.1.0 runtime=node arch=x64 libc= platform=darwin)
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info find Python using Python version 3.7.4 found at "/usr/local/opt/python/bin/python3.7"
gyp info spawn /usr/local/opt/python/bin/python3.7
gyp info spawn args [
gyp info spawn args   '/Users/myuser/.nvm/versions/node/v13.1.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/myuser/Desktop/core-js/node_modules/node-lmdb/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/myuser/.nvm/versions/node/v13.1.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/myuser/Library/Caches/node-gyp/13.1.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/myuser/Library/Caches/node-gyp/13.1.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/myuser/.nvm/versions/node/v13.1.0/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/myuser/Library/Caches/node-gyp/13.1.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/myuser/Desktop/core-js/node_modules/node-lmdb',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CC(target) Release/obj.target/node-lmdb/dependencies/lmdb/libraries/liblmdb/mdb.o
  CC(target) Release/obj.target/node-lmdb/dependencies/lmdb/libraries/liblmdb/midl.o
  CXX(target) Release/obj.target/node-lmdb/src/node-lmdb.o
  CXX(target) Release/obj.target/node-lmdb/src/env.o
../src/env.cpp:139:7: warning: field 'actions' will be initialized after field 'actionCount' [-Wreorder]
      actions(actions),
      ^
../src/env.cpp:141:7: warning: field 'putFlags' will be initialized after field 'env' [-Wreorder]
      putFlags(putFlags),
      ^
../src/env.cpp:166:13: warning: unused variable 'getCount' [-Wunused-variable]
        int getCount = 0;
            ^
../src/env.cpp:239:13: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
            resultsArray->Set(context, resultIndex, Nan::New<Number>(results[resultIndex]));
            ^~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/env.cpp:401:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    obj->Set(context, Nan::New<String>("pageSize").ToLocalChecked(), Nan::New<Number>(stat.ms_psize));
    ^~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/env.cpp:402:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    obj->Set(context, Nan::New<String>("treeDepth").ToLocalChecked(), Nan::New<Number>(stat.ms_depth));
    ^~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/env.cpp:403:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    obj->Set(context, Nan::New<String>("treeBranchPageCount").ToLocalChecked(), Nan::New<Number>(stat.ms_branch_pages));
    ^~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/env.cpp:404:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    obj->Set(context, Nan::New<String>("treeLeafPageCount").ToLocalChecked(), Nan::New<Number>(stat.ms_leaf_pages));
    ^~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/env.cpp:405:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    obj->Set(context, Nan::New<String>("entryCount").ToLocalChecked(), Nan::New<Number>(stat.ms_entries));
    ^~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/env.cpp:429:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    obj->Set(context, Nan::New<String>("mapAddress").ToLocalChecked(), Nan::New<Number>((uint64_t) envinfo.me_mapaddr));
    ^~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/env.cpp:430:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    obj->Set(context, Nan::New<String>("mapSize").ToLocalChecked(), Nan::New<Number>(envinfo.me_mapsize));
    ^~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/env.cpp:431:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    obj->Set(context, Nan::New<String>("lastPageNumber").ToLocalChecked(), Nan::New<Number>(envinfo.me_last_pgno));
    ^~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/env.cpp:432:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    obj->Set(context, Nan::New<String>("lastTxnId").ToLocalChecked(), Nan::New<Number>(envinfo.me_last_txnid));
    ^~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/env.cpp:433:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    obj->Set(context, Nan::New<String>("maxReaders").ToLocalChecked(), Nan::New<Number>(envinfo.me_maxreaders));
    ^~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/env.cpp:434:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    obj->Set(context, Nan::New<String>("numReaders").ToLocalChecked(), Nan::New<Number>(envinfo.me_numreaders));
    ^~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/env.cpp:694:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(Nan::GetCurrentContext(), Nan::New<String>("Env").ToLocalChecked(), envTpl->GetFunction(Nan::GetCurrentContext()).ToLocalChecked());
    ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16 warnings generated.
  CXX(target) Release/obj.target/node-lmdb/src/misc.o
../src/misc.cpp:34:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    versionObj->Set(context, Nan::New<String>("versionString").ToLocalChecked(), Nan::New<String>(str).ToLocalChecked());
    ^~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/misc.cpp:35:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    versionObj->Set(context, Nan::New<String>("major").ToLocalChecked(), Nan::New<Integer>(major));
    ^~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/misc.cpp:36:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    versionObj->Set(context, Nan::New<String>("minor").ToLocalChecked(), Nan::New<Integer>(minor));
    ^~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/misc.cpp:37:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    versionObj->Set(context, Nan::New<String>("patch").ToLocalChecked(), Nan::New<Integer>(patch));
    ^~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/misc.cpp:39:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(context, Nan::New<String>("version").ToLocalChecked(), versionObj);
    ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/misc.cpp:45:46: error: no viable conversion from 'Local<v8::Context>' to 'v8::Isolate *'
    if (opt->IsBoolean() ? opt->BooleanValue(context).ToChecked() : defaultValue) {
                                             ^~~~~~~
/Users/myuser/Library/Caches/node-gyp/13.1.0/include/node/v8.h:2648:30: note: passing argument to parameter 'isolate' here
  bool BooleanValue(Isolate* isolate) const;
                             ^
../src/misc.cpp:249:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    err.As<Object>()->Set(Nan::GetCurrentContext(), Nan::New("code").ToLocalChecked(), Nan::New(rc));
    ^~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/misc.cpp:285:11: warning: extra tokens at end of #endif directive [-Wextra-tokens]
    #endif;
          ^
          //
7 warnings and 1 error generated.
make: *** [Release/obj.target/node-lmdb/src/misc.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/myuser/.nvm/versions/node/v13.1.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 19.0.0
gyp ERR! command "/Users/myuser/.nvm/versions/node/v13.1.0/bin/node" "/Users/myuser/.nvm/versions/node/v13.1.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/myuser/Desktop/core-js/node_modules/node-lmdb

rraallvv avatar Nov 12 '19 05:11 rraallvv

From https://github.com/nodejs/node-gyp/blob/master/macOS_Catalina.md

  • sudo rm -rf $(xcode-select -print-path) # Enter root password. No output is normal.
  • xcode-select --install

cclauss avatar Nov 27 '19 19:11 cclauss

If you have multiple user accounts on your laptop (for instance, I have one for work and one for school, both require using node), and you're tired of uninstalling and re-installing xcode each time you switch user accounts (like what is suggested in https://github.com/nodejs/node-gyp/blob/master/macOS_Catalina.md), you can generally solve this by running the first command suggested in this entire article:

sudo xcode-select --switch /Library/Developer/CommandLineTools

You'll have to do this every time you switch accounts and want to use node; however, it's faster and more preferable than: sudo rm -rf $(xcode-select -print-path) && xcode-select --install

fembuelita avatar Dec 04 '19 22:12 fembuelita

From https://github.com/nodejs/node-gyp/blob/master/macOS_Catalina.md

  • sudo rm -rf $(xcode-select -print-path) # Enter root password. No output is normal.
  • xcode-select --install

I had an existing installation of the CLI tools. (macOS 10.15.2) After deleting the tools and running the install command, a dialog will prompt that it's installing. 👉 NOTE: At the same time you'll get a notification that "Updates are available" – do not dismiss.

After the first installation completes, the tools are not available:

xcode-select -p
xcode-select: error: unable to get active developer directory, use `sudo xcode-select --switch path/to/Xcode.app` to set one (or see `man xcode-select`)

Proceed to accept installing the update from the notification. This process took a bit longer.

After that the path is set:

xcode-select -p
/Library/Developer/CommandLineTools

bgever avatar Dec 17 '19 04:12 bgever

I just reinstall xcode-select by running

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

Solved the gyp issue for me

SimantoR avatar Dec 20 '19 01:12 SimantoR

OS: Mojave 10.14.6 Xcode version: 11.3

As of Jan 2020, for xcode-select to work, it needs to point to xcode.app's location. When I downloaded xcode from developer page, it was directly unpacked in 'Downloads' folder. So, I changed the path to point to downloads folder like so:

sudo xcode-select -switch /Users/(yourUserNameHere)/Downloads/Xcode.app/Contents/Developer

And Boom! It worked after so much struggle. Hope this helps someone.

megharajdeepak avatar Jan 03 '20 12:01 megharajdeepak

The Downloads folder is not a good place to store apps.

cclauss avatar Jan 03 '20 12:01 cclauss

The issue was solved after updating npm:

npm install -g npm@latest

msjaber avatar Jan 10 '20 06:01 msjaber

@davis @gibfahn @bergerjac Thank you so much!

isomorphisms avatar Jan 24 '20 19:01 isomorphisms

OS: version 10.14.5 (18F132) xcode-select: version 2354 Remove and reinstall xcode-select did not resolve this problem on my machine 😭 I installed the latest version of npm too, who else got the same problem with me?

khanhtc1202 avatar Jan 31 '20 12:01 khanhtc1202

@Tibicenas @nitinnain - same here: xcode-select: error: invalid developer directory '/Applications/Xcode-Beta.app/Contents/Developer'

Changing Xcode-Beta.app to Xcode.app in the path should remove this error.

wilpat avatar Feb 04 '20 09:02 wilpat

for anyone who were not able to resolve by reinstalling the xcode-select, you might want to check node version, I know for sure, that with v9 didn't work for me, had to downgrade to v8, didn't try to bump it up to v10 or v12 though. After changing node version just reinstall again and should be good :v:

mvirbicianskas avatar Feb 04 '20 12:02 mvirbicianskas

Same experience: v8 works while v12 did not.

flekschas avatar Feb 25 '20 21:02 flekschas

This is INCORRECT. I am running the latest MacOS Catalina, and the full XCode is required: $ xcodebuild xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

What is the bloody point of having command line tools that require the full blown near 10GB GUI??

ama21n avatar Feb 27 '20 02:02 ama21n

used nvm to install and switch to node version 8.9.3 installed xcode: xcode-select --install accepted the xcode license sudo xcodebuild -license space space space.. agree updated npm to latest npm install -g npm@latest finally both node-gyp rebuild and npm install worked fine 😅

mdezc avatar Mar 12 '20 03:03 mdezc

I just reinstall xcode-select by running

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

Solved the gyp issue for me

Just upgraded MacOS today, together with an xcode update. I guess somehow that upgrade broke xcode command line tools..

clarkttfu avatar Mar 25 '20 11:03 clarkttfu

I'm using the latest MAC OS Catalina v10.15.4 and none of the solutions above worked. For me, I have to download Xcode from the appstore and switch to appropriate node version my site is using and npm install worked!

markanthonyuy avatar Mar 28 '20 05:03 markanthonyuy

I know it looks like silly answer but you may run once XCode app after install by clicking on it (not on terminal).

appbears avatar Mar 30 '20 07:03 appbears

I think xcode-select --install attaches itself to the node version you have installed at the time. So if you're using nvm, asdf or similar, the install process will be linked to the current Node version, and will break if you switch to another version.

iaremarkus avatar Apr 01 '20 11:04 iaremarkus

I just reinstall xcode-select by running

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

Solved the gyp issue for me

It worked on 10.15.4 installing nvm install 8.4.2 Cheers!

u17zl avatar Apr 06 '20 16:04 u17zl