Fix “xcode-select: error active developer directory” on Mac

Apr 26, 2023 - 1 Comment

Terminal in macOS

Some Mac command line users working with nodejs and npm may see an error message and command failure along the lines of “xcode-select: error: tool ‘xcodebuild’ requires Xcode, but active developer directory ‘/Library/Developer/CommandLineTools’ is a command line tools instance”. This error message sometimes appears after updating MacOS, migrating Macs, or

If you experience this error message, you’ll likely be able to fix it rather simply.

Solution 1: Install Command Line Tools

The easiest solution is simply to install command line tools on the Mac, which can be done from the command line. You can also simply install the full Xcode suite from the Mac App Store if you’re inclined to do so.

  1. Launch the Terminal and enter the following command to initiate the installation of Command Line Tools
  2. xcode-select --install

  3. Proceed with installation when prompted

That alone may fix the “xcode-select error xcodebuild requires Xcode” error message.

Solution 2: Switch Directory for Command Line Tools

Sometimes, if you installed Xcode and Command Line Tools separately, you may need to re-specify the directory that is in use for command line tools with the following command entered into the Terminal:

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

Solution 3: Install Xcode and Change Location for Command Line Tools

Another approach involves the full Xcode package which you can download from Apple.

  1. Open Xcode on the Mac, then pull down the Xcode menu and choose Preferences
  2. Go to “Locations” and select the proper Command Line Tools

Solution 4: Install Xcode into /Applications, Switch Directory Accordingly

And finally, another solution that has worked for some users when the above approaches do not work, is to install Xcode from the Mac App Store into the /Applications/ directory on the Mac. After Xcode is installed on the Mac, open the Terminal and enter the following path:

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

Which of these tricks worked to fix the “xcode-select: error: tool ‘xcodebuild’ requires Xcode, but active developer directory ‘/Library/Developer/CommandLineTools’ is a command line tools instance” error message for you on your Mac? Did you find another solution? Let us know in the comments.

.

Related articles:

Posted by: Jamie Cuevas in Mac OS, Troubleshooting

One Comment

» Comments RSS Feed

  1. MikeD says:

    Thanks for the fix!

    Solution 3: Install Xcode and Change Location for Command Line Tools

    Action: Trying to open Unreal Engine project. It requires Metal to build.

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site