Hot to fix 'xcrun: error: invalid active developer path, missing xcrun' on macOS
Mar 26, 2023
1 min read
When using a brand-new Mac computer, or sometimes after upgrading macOS to a new version, it is possible that when you try to use git
, the terminal returns an obscure error like this:
$ git status
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools),
missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
What it really happens, is that you are missing the Apple Developer Tools, which are required to use git
and other command line tools like some compilers. They can be wiped after some updates, so you'll need to reinstall them.
How to fix it
So te solution is pretty simple, you just need to install the Apple Developer Tools, and they come bundled with XCode.
However, XCode is a pretty big package, and you'll only need it if you are developing iOS apps, so we'll install only the command line tools, which are much smaller.
To do that, open a terminal and run the following command:
xcode-select --install
You will be prompted to install the command line tools.
Allow the installation (it may ask for your password and require you to accept the XCode license) and let it download the required packages. It should take only a few minutes, depending on your internet connection speed. After that, you should be able to use git
again.
Still not working?
If the above didn't work for you, here are some steps that may help:
- Try rebooting your computer (seriously, sometimes this can fix it).
- Try running
xcode-select --install
again. Also, try runningxcode-select --reset
to reset the xcode config to default values. - If none of the above worked, try to install the full XCode IDE. You can get it from the App Store. Also, you can get the
.dmg
directly from the Apple Developer website.