136

I get this error when I run brew update:

$ brew update
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Error: Failure while executing: git checkout -q master

How to fix this issue?

At0micMutex
  • 3,551

5 Answers5

176

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.

  • 11
    I had to add sudo xcode-select -switch /Library/Developer/CommandLineTools/ instead of just sudo xcode-select -switch / but otherwise this worked great. No need for me to chown the files though. – TunaMaxx Oct 19 '15 at 20:51
  • 2
    And don't forget to restart terminal after any new installs.. – youngrrrr Aug 30 '18 at 08:10
55

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/

3

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

nohillside
  • 100,768
c.buster
  • 31
  • 1
2

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.

trusktr
  • 1,391
2

@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
bmike
  • 235,889
  • That might because your path was correct, but the command line tools were outdated. Nice that you got it done! But did you really need to use sudo? – anki Oct 19 '19 at 15:09
  • Needing sudo is a sign that you have a non-standard setup. It may not be wrong for you, but will confuse others and doesn’t follow the out of the box macos and brew.sh idiom. I would run brew doctor and fix any permissions issues rather than force things with sudo here. Also, what was correct when this was asked may have changed so I won’t -1 this even though it doesn’t hold for macOS Catalina. – bmike May 30 '20 at 16:29