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?

0

5 Answers 5

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.

2
  • 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, 2015 at 20:51
  • 2
    And don't forget to restart terminal after any new installs..
    – youngrrrr
    Aug 30, 2018 at 8: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/

1
  • This is better than the selected answer because it simpler and doesn't use sudo. It worked after my Catalina upgrade. I didn't even need to restart Terminal.
    – wisbucky
    Dec 27, 2021 at 3:30
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

2
  • Actually, that's not what the error message was saying, xcrun is no longer at that path. It was a bug/incompatibility issue with homebrew that was fixed years ago. May 30, 2020 at 14:40
  • Thanks for the clarification on that!
    – c.buster
    Jun 7, 2020 at 20:31
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.

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
2
  • 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, 2019 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, 2020 at 16:29

Not the answer you're looking for? Browse other questions tagged .