[macos] Command Line Tools not working - OS X El Capitan, Sierra, High Sierra, Mojave

I just upgraded from Yosemite to El Capitan (and replicated the problem upgrading from El Capitan to Sierra), and when I try to type for example git status inside a terminal, I get the following error:

xcrun: error: invalid active developer path
 (/Library/Developer/CommandLineTools), missing xcrun at:
 /Library/Developer/CommandLineTools/usr/bin/xcrun

I don't have Xcode installed, never did. Anyone have a solution?

This question is related to macos macos-sierra osx-elcapitan macos-high-sierra

The answer is


Found the fix for the problem here.

xcode-select --install

This will bring up a prompt to install the necessary command line tools.


I tried the solution xcode-select --install but it don't help me, I update from Sierra to High and happened this, my solution:

sudo xcode-select --reset

For Mojave

Uninstall Any old version of Command Line Tools:

sudo rm -rf /Library/Developer/CommandLineTools

Download and Install Command Line Tools 10.14 Mojave.


For me, after I've removed Xcode, I have to switch active developer path as follows: sudo xcode-select -s /


Updated to High Sierra 10.13.2

xcode-select --install ALONE did not work for me.

  1. Download X-code from app store
  2. $xcode-select --install
    a. May need to update after install using softwareupdate in command line. $sudo softwareupdate -i "Command Line Tools (macOS High Sierra version 10.13) for Xcode-9.1"

  3. $sudo xcodebuild -license


After update to macOS 10.13.3

After updating do macOS 10.13, I had to install "Command Line Tools (macOS 10.13) for Xcode 9.3" downloaded from https://developer.apple.com/download/more/


In macOS 10.14 this issue may also occur if you have two or more versions installed. If you like xCode GUI you can do it by going into preferences - CMD + ,, selecting Locations tab and choosing version of Command Line Tools. Please refer to the attached print screen.

enter image description here


For the most recent version Mojave version 10.14.1, I use

solved by downloaded from https://developer.apple.com/download/more/ " login by apple id, and download

Command line tool newest stable version.dmg

That makes everything work

the old answer

xcode-select --install

doesn't work for me.


I just updated to High Sierra and I couldn't just run xcode-select --install. First, I had to actually install xcode from the app store. Then I ran xcode-select --install. Then I had to run sudo xcodebuild -license, agree to the terms, then I could finally run git commands again.


I upgraded mac os to macOS High Sierra - 10.13.3 and faced a similar issue while trying to install watchman (with command - brew install watchman).

ran the command: xcode-select --install, then ran "brew install watchman" - Everything works fine!


I had the same issue after upgrading to macOS Catalina. This didn't work for me:

xcode-select --install

Downloading and installing Command Line Tools for Xcode 12 did it!

enter image description here


Reassigning the path Xcode is configured with worked for me.

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

You'll then likely be prompted (after trying a command) to agree to the license agreement.


If you have issues with the xcode-select --install command; e.g. I kept getting a network problem timeout, then try downloading the dmg at developer.apple.com/downloads (Command line tools OS X 10.11) for Xcode 7.1


For those also having issues with heroku command line tools after upgrading, I also had to do the following in my terminal:

xcode-select --install 
brew install heroku/brew/heroku
brew link --overwrite heroku

It seems the upgrade to High Sierra messed with my symlinks in addition to forcing me to reinstall xcode tools. I kept getting 'not a directory' errors:

? stat /Users/mattymc/.local/share/heroku/client/bin/heroku: not a directory  
? fork/exec /Users/mattmcinnis/.local/share/heroku/client/bin/heroku: not a directory 

Hope that saves someone an hour :)


Even if you do xcode-select --install it was not fixing that for me as it showed some network error. The problem was that it could not connect to the app store. I did the following to fix it.

  1. Open keystore
  2. Go to system root and select certificates.
  3. Open digicert high assurance EV.
  4. Expand the trust section, mark it as never trust.
  5. Restart system now repeat step 1, 2, 3. and mark the trust policy as back to use system defaults.

Your app store should work now and you should be able to run xcode-select --install


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 macos-sierra

Cannot connect to the Docker daemon on macOS Command Line Tools not working - OS X El Capitan, Sierra, High Sierra, Mojave

Examples related to osx-elcapitan

How to install wget in macOS? Mysql password expired. Can't connect OSX El Capitan: sudo pip install OSError: [Errno: 1] Operation not permitted Command Line Tools not working - OS X El Capitan, Sierra, High Sierra, Mojave Operation Not Permitted when on root - El Capitan (rootless disabled) Setting environment variables via launchd.conf no longer works in OS X Yosemite/El Capitan/macOS Sierra/Mojave?

Examples related to macos-high-sierra

Is it possible to install Xcode 10.2 on High Sierra (10.13.6)? ERROR in Cannot find module 'node-sass' Command Line Tools not working - OS X El Capitan, Sierra, High Sierra, Mojave