I updated to the latest OS, and/or restarted my computer (this happens on every major update, but this time all I did was restart my computer on 2022-09-13)
This morning I navigated to my work's codebase in the Command Line on my MacBook pro, typed in "git status" in the repository and received an error:
(IN 9/2022, this error was much different, but I didn't capture it)
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
git will not work!
How do I fix git, and command line tools?
Conclusion. The xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) error is raised when you try to run a git command without having Xcode Tools installed. To fix this error, run xcode-select –install and install Xcode Tools.
xcrun is a tool that helps managing Xcode versions on your system. It allows you to write scripts that don't need to know where your Xcode instance or developer tools are installed. The path to the Xcode version (or developer tools) is set/read via xcode-select . You can reset it via: sudo xcode-select --reset.
We'll use Finder to find out if XCode is installed. In Finder, select the Go pull-down menu, and select Applications. Or just use the short-cut key Command-Shift-A while Finder is active. This should open a new Finder window, showing all the Applications installed on your machine.
The problem is that Xcode Command-line Tools needs to be updated.
** UPDATED FOR Sept. 2022 M1 MacBook Pro **
After opening the terminal after a restart, I tried to go to my code, and do a git status, and I got an error and prompt for command line software agreement.
So press space until you get to the [agree, print, cancel]
option, so careful hit space to scroll down to the end, if you blow past It you have to run a command to get it back. Use sudo xcodebuild -license
to get to it again.
Just be careful on scrolling down and enter agree
and press return and it will launch into an update.
Then I tried to use git after the install, and it prompted me to install Xcode tools again.
I followed my own advice from previous years (see below), and went to https://developer.apple.com/download/more/ and downloaded "Command Line Tools for Xcode 14" (You have to log in with your Apple ID, so have that login readily available.
** I am not sure if this step is needed, but I did it all the same as that's what worked the previous years.
Before you can use git, you need to reboot!!! SUPER IMPORTANT
This will break the cycle and completed the installation and your CLI tools including git will now work.
Solutions for previous years, these may or may not be valid these days as the downloads page has changed significantly:
PREVIOUS YEARS SOLUTIONS, probably #2 is most helpful.
** Solution #1 **
Go back to your terminal and enter:
xcode-select --install
You'll then receive the following output:
xcode-select: note: install requested for command line developer tools
You will then be prompted in a window to update Xcode Command Line tools. (which may take a while)
Open a new terminal window and your development tools should be returned.
Addition: With any major or semi-major update you'll need to update the command line tools in order to get them functioning properly again. Check Xcode with any update. This goes beyond Mojave...
After that restart your terminal
Alternatively, IF that fails, and it very well might.... you'll get a pop-up box saying "Software not found on server", see below!
Solution #2
and you hit xcode-select --install
and it doesn't find the software, log into Apple Developer, and install it via webpage.
Log in or sign up here:
https://developer.apple.com/download/more/
Look for: "Command Line Tools for Xcode 14.x" in the list of downloads Then click the dmg and download.
I got some errors that the software was unavailable from the update server when trying
xcode-select --install
What fixed it for me was going here https://developer.apple.com/download/more/ and downloading Command Line Tools (macOS 10.14) for Xcode 10
and then installing it manually.
After that, the errors should be gone when you open up a new terminal.
For me xcode-select --reset
was the solution on Mojave.
In addition to dustbuster's answer I needed to set path to the Xcode folder with this command:
sudo xcode-select -switch /Library/Developer/CommandLineTools
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With