How to fix homebrew error: "invalid active developer path" after upgrade to OS X El Capitan?

Run the following commands to fix the above error

sudo xcode-select --install
sudo xcode-select -switch /

I found the answer on https://github.com/Homebrew/homebrew/issues/23500

I also had to do this:

sudo chown -R $(whoami):admin /usr/local

Because of some permission issues. However, do this only if you have to.


Only the following command should resolve the issue if you are the admin on the machine.

xcode-select --install

The following article helped me solve the issue

http://tips.tutorialhorizon.com/2015/10/01/xcrun-error-invalid-active-developer-path-library-developer-commandline-tools-missing-xcrun/


I got this problem after updating macOS to Mojave (maybe updating the OS can causes this).

To fix it, I simply installed Xcode from the App Store instead of doing the command line stuff.


@Ranjith Ramachandra answer but I was able to get everything to work by only running the install command with sudo so if you’ve got modified permissions, forcing root may be needed

sudo xcode-select --install

I got this error after updating to Catalina 10.15 here is what I found:

The error is alerting you that you need to (re) install X-code command-line tools.

run

xcode-select --install

after this, run

brew outdated

then

brew upgrade

While Homebrew automatically uninstalls old versions of formulas every 30 days you can still run the following to get ride of any unneeded stuff.

brew cleanup -n  

and

brew cleanup

To learn more about homebrew check out the documentation on https://docs.brew.sh/FAQ