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

u can try it,hope can helps u

Thanks!! This worked for me

This worked for me! thanks for sharing.

You saved my day ! :heart:

This worked for me! Thanks.

I fix this issue via these steps.

  1. go to https://developer.apple.com/download/more/ and download latest Command Tools
  2. manually install Command Tools

That worked for me, I installed the 10.14.1 version as the older version running on a new mac which was running 10.14

sudo xcode-select -s /Library/Developer/CommandLineTools fixed it for me.

1 Like

I kept following the “easy” advice to run xcode-select --install and it kept timing out and ending in error (in OSX 10.14 Mojave). Following these steps XCode --> Open Developer Tool --> More Developer tools and download the Command Line Tools was the solution

Thanks. It worked for me!

Hello. My company does not allow me to connect Apple to download/install.
But I do have admin rights on my Mac (Sierra 10.12.6) and was able to resolve
brew install by capturing install script (curl https://raw.githubusercontent.com/Homebrew/install/master/install > Homebrew_install.ruby) , edit script: comment out the install and for good measure allow --switch to point at /Applications/Xcode.app/Contents/Developer. Execute: /usr/bin/ruby ./Homebrew_install.ruby Good luck!

Can you please provide me the edited script I am a noob please provide me edited script and tell me how to install the script. This is my email address can you please send me the edited script on my email


I ran into this on a new Mac OS X 10.14.5 machine.
First, I installed XCode via the AppStore. Then I opened up a terminal and ran the cURL call to install Homebrew. That’s when I got this error:

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

It was then I realized I hadn’t launched XCode yet and wondered if that was related. I launched XCode, agreed to the Terms of Service and finalized the install. Once that was done, the cURL command worked and I was able to install Homebrew successfully.

P.S. If this still doesn’t work for you, it’s easy to download the Command Line Tools installer from Apple’s Developer Site search for XCode

You don’t need to manually download it. xcode-select --install will do that for you.

Except when that is what is giving you the error. See the error above.

When you can’t get the package via the xcode-select command, you might have to get the package yourself. If other mitigations don’t resolve the issue, my “P.S.” section was meant to get folks unblocked.

The error is in a different invocation of the xcode-select command. --switch will switch directory. --install will install

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

This worked for me in a new install of Mojave.

Thank you.

1 Like

thank you so much, this ended an hour of pain

This worked for me as well. First I got Xcode from AppStore and then loaded correct version of Command line from https://developer.apple.com/download/more/

Okay, let me be as explicit as possible:

  1. Obtain fresh os X install (in my case, 10.14.5), install XCode from AppStore or developer.apple.com
  2. Install Homebrew with the usual cURL command
  3. Encounter error seen by other individuals reported above
  4. Locate this forum, note instruction to try xcode-select --install
  5. Run that command. Encounter same error as above.
  6. …Try a lot of things that don’t work…
  7. Use the steps I posted in my initial response, that eventually DID work.
  8. Post here in case anyone encounters that same problem, as described in #3 / #4

Does that help?