[xcode] xcode-select active developer directory error

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?

This question is related to xcode macos npm npm-install command-line-tool

The answer is


Simple reinstall xcode-select

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

For context, today is Jan 28, 2019.

On my Mac, I did two things to resolve this problem:

  1. Run the following command in your terminal:
    sudo xcode-select --install

  2. Restart your Mac.

Until I restarted the computer, the problem kept occurring in my Android Studio. After reboot, it was working just fine. Also note that I did not execute any --switch commands as others are doing. I hope this helps.


Just in case you're using xcode beta:

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

None of the above worked for me. I originally installed Command Line Tools separately, and then all of Xcode. What worked for me was to uninstall Command Line Tools as shown here. Then, when trying to run xcode-select again, I was asked to reinstall them.

*By the way, the very reason why I found this thread was because I had installed some libraries (particularly gcc) with macports, presumably using the old Command Line Tools, and then I installed the full Xcode midway into development. So anyways, for my case, I had to reinstall macports after removing the stand-alone Command Line Tools, reinstalling them, reinstalling gcc, and then my compilation worked.


Other solution for those who don't want to install Xcode:

  1. Install Command Line Tools (if you haven't already):

    xcode-select --install

  2. Change the active directory:

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

This worked for me (git).


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!


Please follow the steps below :

  1. The latest version of Xcode can be downloaded from https://developer.apple.com/xcode/download/
  2. It will be downloaded in the 'Downloads' unless specified otherwise. Please make sure to check the path where you have downloaded and extracted the Xcode
  3. Now unlike other downloaded applications, on extraction, Xcode doesn't give the option to move it to Applications
  4. Note the XCODE-ACTUAL-LOCATION or move it to the Applications
  5. Note if you have downloaded Xcode or Xcode-beta

Based on 4 and 5, execute one of the commands (Do not execute all of them without reading above description):

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer
sudo xcode-select -s /[XCODE-ACTUAL-LOCATION]/Xcode.app/Contents/Developer
sudo xcode-select -s /[XCODE-ACTUAL-LOCATION]/Xcode-beta.app/Contents/Developer

In case you are using Xcode beta, run

sudo xcode-select --switch /Applications/Xcode-beta.app/Contents/Developer 

instead of

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

Without Xcode: create file /usr/local/bin/xcodebuild with content to cheat XcodeSelect

  #!/bin/bash
  exit 0

chmod +x /usr/local/bin/xcodebuild


Manually installing Command LineTool worked for me.

  1. I stalled xcode through App Store
  2. Still could not download Homebrew
  3. I installed Command Line Tool manually through link.
  4. Bing Bang Boom

https://developer.apple.com/download/more/?=command%20line%20tools


XCode2: sudo xcode-select -s /Applications/Xcode\ 2.app/Contents/Developer

Pay attention to the "\" to escape the space


I was able to solve this error without installing the full Xcode application. You must, however, have xcode command line tools installed.

From here:

  1. $ cd /usr/bin
  2. $ sudo mv xcodebuild xcodebuild.orig (A backup just in case)
  3. $ vim xcodebuild
  4. Paste the following:
#!/bin/bash
if [[ $1 == '-version' ]]; then
  echo "Xcode 10.2.1"
  echo "Build version 10E1001"
else
  /usr/bin/xcodebuild.bak $@
fi
  1. $ sudo chmod +x xcodebuild

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:

  1. "xcode-select --print-path" is equal to "/Applications/Xcode.app/Contents/Developer"
  2. "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform" exists
  3. "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


I had to run this first

sudo xcode-select --reset

then

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

and then it worked.


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.


In my case,

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

didn't work because my Xcode had some special name. eg) Xcode_11.2.0_beta_2_stackoverflow.app

cd /applications
ls

Then I found my Xcode name, then replace it with

sudo xcode-select -s /Applications/{myXcodeName}.app/Contents/Developer 

It worked for me.


Xcode > Preferences > Locations > Command Line Tools

screenshot

Select the option matching your version of Xcode.


  1. Download Xcode from App Store.

  2. Go to Xcode preferences/Locations/CommandlineTools

    You just have to set it to the Xcode version. It automatically points to '/Application/Xcode.app'


Type this in your terminal

xcode-select --install
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license accept

There are only two steps required, and the full XCode.app is not required at all:

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

At this point the "Installing Softwre" dialog pops up:

enter image description here

That's it!


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.

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.


I was having the same problem in high sierra. running the following command solved it

npm explore npm -g -- npm install node-gyp@latest

Examples related to xcode

Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64 iPhone is not available. Please reconnect the device Make a VStack fill the width of the screen in SwiftUI error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65 The iOS Simulator deployment targets is set to 7.0, but the range of supported deployment target version for this platform is 8.0 to 12.1 Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Xcode 10: A valid provisioning profile for this executable was not found Xcode 10, Command CodeSign failed with a nonzero exit code

Examples related to macos

Problems with installation of Google App Engine SDK for php in OS X dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac Could not install packages due to an EnvironmentError: [Errno 13] How do I install Java on Mac OSX allowing version switching? Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Can't compile C program on a Mac after upgrade to Mojave You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user) How can I install a previous version of Python 3 in macOS using homebrew? Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'"

Examples related to npm

What does 'x packages are looking for funding' mean when running `npm install`? error: This is probably not a problem with npm. There is likely additional logging output above Module not found: Error: Can't resolve 'core-js/es6' Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist` ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.2.0 but 3.2.1 was found instead DeprecationWarning: Buffer() is deprecated due to security and usability issues when I move my script to another server Please run `npm cache clean` What exactly is the 'react-scripts start' command? On npm install: Unhandled rejection Error: EACCES: permission denied Difference between npx and npm?

Examples related to npm-install

How to update core-js to core-js@3 dependency? Can not find module “@angular-devkit/build-angular” How do I deal with installing peer dependencies in Angular CLI? NPM Install Error:Unexpected end of JSON input while parsing near '...nt-webpack-plugin":"0' How to solve npm install throwing fsevents warning on non-MAC OS? Why does "npm install" rewrite package-lock.json? What is the difference between npm install and npm run build? How to solve npm error "npm ERR! code ELIFECYCLE" base 64 encode and decode a string in angular (2+) Install specific branch from github using Npm

Examples related to command-line-tool

Xcode 6.1 - How to uninstall command line tools? xcode-select active developer directory error What is a faster alternative to Python's http.server (or SimpleHTTPServer)? How to install Xcode Command Line Tools