Why am I getting an “invalid active developer path” when attempting to use Git after upgrading to macOS Monterey?
Solution
Open Terminal, and run the following:
xcode-select --install
This will download and install the Command Line Tools package and fix the problem.
You do not need Xcode, you can install only the Command Line Tools here, it is about 130Mb.
If the above alone doesn't do it, then also run:
sudo xcode-select --reset
Further reading
The problem is that one needs to explicitly agree to the license agreement. As a follow on step, you may need to reset the path to Xcode if you have several versions or want the command line tools to run without Xcode.
sudo xcode-select --switch /Applications/Xcode.app
sudo xcode-select --switch /Library/Developer/CommandLineTools
I found the solution in this question, Command Line Tools not working.
You may get an error message: "Can't install the software because it is not currently available from the Software Update server". In this case xcode-select --reset
works as pointed by akozin.
If you don't want to install nor use Xcode (I don't) you can install only
command tools for Xcode (please see Edit)
Preconditions:
- you have AppleID
Solution
Go to https://developer.apple.com/download/more/ and find Command line tools OS X 10.11) for Xcode 7.1. Then install downloaded .dmg package.
Newer versions
It should work with newer versions of Command line tools OS X however I tested it Command line tools OS X 10.11) for Xcode 7.1 particular version.
Update to macOS 10.13
After updating do macOS 10.13, I had to install Command Line Tools (macOS 10.13) for Xcode 9
- also works great.
Edit
As @setholopolus mentioned in comment,
xcode-select --install
Also installs only command line tools for Xcode.
You can also verify this at: http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/
I am leaving my answer in case you'd have problems with installation via cli
.
PS credits to this SO answer: https://stackoverflow.com/a/33593066/2029818