Xcode-select: error: invalid developer directory '/Library/Developer/CommandLineTools' Failed during: /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools

(Eva) #1

Hi, I’m getting this error while installing. I used the installation command sr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)” and all goes well past entering password. In the end I get this error. Can you tell me how to solve it. I’m new to Mac and just used the terminal for the first time.

(Mike McQuaid) #2

What version of macOS are you running?

(Eva) #3

HI Mike, I’m using Sierrra 10.12.3

(Mike McQuaid) #4

Try to run xcode-select --install and run the installer again. Thanks!

(StealthBadger747) #5

Sorry to bring up an old thread, but I am having the same issue, with High Sierra 10.13.1 and I cannot run xcode-select --install because it says 'cannot install software once I run it an it tries downloading. Thus I installed full xcode and it still doesn’t work.

This is the output:

xcode-select: error: invalid developer directory '/Library/Developer/CommandLineTools'
Failed during: /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools

(MaheshC) #6

I am having the same issue on High Sierra 10.13.2. Installed xcode from the App Store but still it doesn’t work.

xcode-select: error: invalid developer directory '/Library/Developer/CommandLineTools' Failed during: /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools

(Prtysh) #7

Facing the same issue. The installer is pointing at the wrong path for Xcode. Trying to understand how to correct it.


Has anyone found a solution for this? I’m receiving the same error and have the same problem with the install.

(Mick Mak) #9

Try to install the command line tools following this answer if you are using Mac:

brew seems checks if the command line tools installed in this path:


My case is: I tried to install brew on my new mac. After I installed Xcode, there was nothing in the above path but the command line tools were somehow installed to another location. (xcode-select -p tell me it was /Applications/Xcode.app/Contents/Developer)
The way in stackoverflow can install the command line tools to


Now I got brew working. But I am not sure if it is the best solution as there should be two copies of command line tools on my machine using this method.

(Huangrongfu) #10

thanks, i run

xcode-select --install

and it is work

(Shuchitaprasad) #11

The reason for this issue is that Xcode is not installed. I installed Xcode first, then went to https://developer.apple.com/download/more/ after which I logged with my apple id and then selected command line toll corresponding to my Xcode version. After this error was resolved

(Drigomaniac) #12

I had the same problem in OSX 10.13.4 Sierra.

You just need to install a component of XCode call Command Line Tools.

XCode --> Open Developer Tool --> More Developer tools --> (Login with Apple., the annoying part) and download the Command Line Tools

Install and re-run homebrew installation.

(Sean Molenaar) #13

The easier way is running this:

(Robert Mc Elvenny) #14

I’m still getting this error, I’ve tried everything.

Deleting all traces of Xcode, deleting Command Line Tools, manually downloading, re-running, etc, etc it continues to happen and I can’t find a solution.

/usr/bin/sudo /usr/sbin/softwareupdate -i Command\ Line\ Tools\ (macOS\ version\ 10.14)\ beta\ 3\ for\ Xcode-10.0
Software Update Tool

Downloading Command Line Tools (macOS version 10.14) beta 3 for Xcode
Downloaded Command Line Tools (macOS version 10.14) beta 3 for Xcode
Installing Command Line Tools (macOS version 10.14) beta 3 for Xcodexcode-select --install

Done with Command Line Tools (macOS version 10.14) beta 3 for Xcode
==> /usr/bin/sudo /bin/rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
==> /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools
==> Installing the Command Line Tools (expect a GUI popup):
==> /usr/bin/sudo /usr/bin/xcode-select --install
xcode-select: error: command line tools are already installed, use “Software Update” to install updates
Failed during: /usr/bin/sudo /usr/bin/xcode-select --install

macOS Mojave, I’ve downloaded beta Xcode, including the Command Line Tools, I’ve done pretty much everything and 5 days worth of stackoverflow search. What might be the issue (I know Beta software is asking much )

(Sean Molenaar) #15

What i dont really see what part of your problem is homebrew related. Are the last commands run by homebrew?

(Robert Mc Elvenny) #16

Yes, Homebrew tries to download and install or use xcode-select --install even though the CommandLineTools are already available. I’m not entirely sure why this keeps happening either, maybe I will have to modify the ruby script.

(Robert Mc Elvenny) #17

I commented out line 277 of the homebrew ruby install script and ran it on my terminal again locally, it bypassed xcode-select --install and began to install the homebrew script.

   # Headless install may have failed, so fallback to original 'xcode-select' method
if should_install_command_line_tools? && STDIN.tty?
  ohai "Installing the Command Line Tools (expect a GUI popup):"
  # sudo "/usr/bin/xcode-select", "--install"
  puts "Press any key when the installation has completed."
  sudo "/usr/bin/xcode-select", "--switch", "/Library/Developer/CommandLineTools"

that worked and I can run brew commands now.

(Sayooj Krishnan) #18

Thanks for the fix !!

Sorry Mojave question about SDK and upgrade