I updated to macOS Mojave (this happens on Catalina update too, and seems to potentially occur on every major update thereafter)
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 the error:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
How do i fix git, and command line tools?
This question is related to
xcode
git
macos
command-line
terminal
The problem is that Xcode Command-line Tools needs to be updated.
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.
Login or sign up here:
https://developer.apple.com/download/more/
Look for: "Command Line Tools for Xcode 12.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
I've used xcode-select --install
given in the accepted answer in previous major releases.
I've just upgraded to OS X 10.15 Catalina and run the Software Update tool from preferences again after the OS upgrade completed. The Xcode utilities update was available there, which also sorted the issue using git which had just output
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)
For me what worked is the following:
sudo xcode-select --reset
Then like in @High6's answer:
sudo xcodebuild -license
This will reveal a license which I assume is some Xcode license. Scroll to the bottom using space (or the mouse) then tap agree
.
This is what worked for me on MacOS Mojave v 10.14.
After upgrade to Mac Catalina
I faced the same issue, I had to run couple of commands to get this fixed.
First started with:
xcode-select --install
It didn't fix the problem, had to run the following in sudo
sudo xcode-select --reset
Then, finally got fixed after I switched and set the path explicitly for active developer directory:
sudo xcode-select -s /Library/Developer/CommandLineTools
Note: In case you have Xcode
installed, you may need to specify Xcode
directory in this case, it should be something like this
xcode-select -s /Applications/Xcode.app
updated from Mojave to Big Sur and got the same error : the command
xcode-select --install
worked like a charm
I figured out the Xcode Command Line Tools part from the error message, but after running Xcode and getting the prompt to install the additional tools it did claim to install them, but still I got the same error after opening a new terminal.
So I did the xcode-select --install
manually and after that it worked for me.
Open Terminal:
install XCode developer tools and fix the problem.
$ xcode-select --install
Reset the path to Xcode if you have several versions:
$ xcode-select --switch /Applications/Xcode.app
$ xcode-select --switch /Library/Developer/CommandLineTools
If you have Xcode downloaded manually (i.e. not from the App Store) or don't have Xcode at all:
sudo rm -rf /Library/Developer/CommandLineTools
If you have Xcode installed from the App Store:
xcode-select --install
Mac OS : Big Sur
First Priority
sudo xcode-select --reset
sudo xcodebuild -license
Second Priority
xcode-select --install
On Mac OS X Catalina the following worked just fine
xcode-select --install
After this, a UI prompt showed up and that complete the install of the tools
On the latest version of MacOS Big Sur (clean/first install)
This command works as it should and installs Xcode
xcode-select --install
Following worked on M1
ProductName: macOS
ProductVersion: 11.2.1
BuildVersion: 20D74
% xcode-select --install
Agree the Terms and Conditions prompt, it will return following message on success.
% xcode-select: note: install requested for command line developer tools
For me, I didn't have xcode installed (on Mojave OS). I went to the App Store on my mac and downloaded it, then went back to terminal and typed git
and hit enter, then it worked.
This works for me
sudo xcode-select --reset
sudo xcodebuild -license
X-code must be installed.
I found that my version of Xcode was too outdated and installing command-line-tools wasn't helping. Here's what I did:
Try this:
sudo xcode-select --reset
sudo xcodebuild -license
or this:
xcode-select --install
For me It happened after Mac OS update to Mojave and git was not functioning in Intellij
Solution:- Go to Settings, then File | Settings | Version Control | Git and edit Path to Git executable field which is /usr/local/bin/git
For those using Catalina and Xcode-beta:
sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer
I had the same issue and couldn't use SVN after the update,
Just in case if doing xcode-select --install didn't fix the issue,
You might see,
svn: error: The subversion command line tools are no longer provided by Xcode.
Refer : https://developer.apple.com/documentation/macos_release_notes/macos_catalina_10_15_release_notes
Try installing the svn by brew
brew install svn
This should get you going.
If for any chance you don't have to Xcode or had to delete it, e.g. in a situation when you needed to free up disc space in order to perform update simply install Xcode from the App Store. Once it'll be done and when you'll be launching this for the first time Xcode will ask you if you'd like to install components, click Install
and it'll fix the issue as well.
For me, none of the solutions work. I had to download the XCode from the App store. It's too big around 12 GB. After installing it works like a charm.
If you created a new Applications folder in an external drive and installed Xcode there:
sudo xcode-select --switch /Volumes/MyExternalStorageName/Applications/Xcode.app/Contents/Developer
Source: Stackoverflow.com