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?
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.
Log in 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.
https://i.stack.imgur.com/WwAlF.png
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.
software not available at server
but @High6's answer below works. xcode-select --reset
Command Line Tools (macOS 10.14) for Xcode 10.1
from the link. thanks!
Command Line Tools for Xcode 11.3
, since Xcode 10.1 wasn't available
For me xcode-select --reset
was the solution on Mojave.
xcode-select --install
.
sudo
sudo xcode-select --reset
worked for me on a Mojave --> Catalina upgrade of MacOS
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
xcode-select --install
and downloading and installing manually, none of the solutions worked. Note that I waited and upgraded to version 10.14.1.
xcode-select --switch /Applications/Xcode.app/Contents/Developer
or xcode-select --reset
so Terminal will use the command line tools inside Xcode instead of the ones installed by the "command line tools" standalone installer. From then on, the App Store will auto-update Xcode and your tools will stay current.
updated from Mojave to Big Sur and got the same error : the command
xcode-select --install
worked like a charm
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
xcode-select --switch /Applications/Xcode.app/Contents/Developer
or xcode-select --reset
so Terminal will use the command line tools inside Xcode instead of the ones installed by the "command line tools" standalone installer. From then on, the App Store will auto-update Xcode and your tools will stay current.
sudo xcode-select --reset
first then --install
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)
xcode-select --switch /Applications/Xcode.app/Contents/Developer
or xcode-select --reset
so Terminal will use the command line tools inside Xcode instead of the ones installed by the "command line tools" standalone installer. From then on, the App Store will auto-update Xcode and your tools will stay current.
in my case it wasn't checked in xcode After installation process ,
you can do that as following : xcode -> Preferences and tap Locations then select , as the followng image
https://i.stack.imgur.com/HKpHR.png
xcode-select --switch
with the path to the Xcode package of whatever version you select here, by the way.
If you use xcode
then install it (~12GB)
xcode-select --install
Otherwise install latest command line tools (~500MB)
https://i.stack.imgur.com/8eJ3h.png
Mac OS : Big Sur
First Priority
sudo xcode-select --reset
sudo xcodebuild -license
Second Priority
xcode-select --install
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.
xcode-select --switch /Applications/Xcode.app/Contents/Developer
or xcode-select --reset
so Terminal will use the command line tools inside Xcode instead of the ones installed by the "command line tools" standalone installer. From then on, the App Store will auto-update Xcode and your tools will stay current.
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
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 Go to https://developer.apple.com/download/more/ to download Command Line Tools (macOS 10.14) for Xcode 10 Setup Command Line Tools
If you have Xcode installed from the App Store:
xcode-select --install
xcode-select --install
answer I had an error from the UI installer: "xcode-select: note: install requested for command line developer tools". This was the only thing that worked for me since I didn't want to install Xcode. (I used the Command Line Tools for XCode 12.)
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
xcode-select --switch /Applications/Xcode.app/Contents/Developer
or xcode-select --reset
so Terminal will use the command line tools inside Xcode instead of the ones installed by the "command line tools" standalone installer. From then on, the App Store will auto-update Xcode and your tools will stay current.
xcode-select --switch
above. The second one overwrites what the first one did. Do the first one and your command line tools will update as part of Xcode.
Run this command:
xcode-select --install
Hit return for a progress indicator on the Command Line Tools download. After installation of the Command Line Tools has been completed, your Mac should be rebooted. If you’re getting “xcrun error invalid active developer path” while working in Terminal, refresh the application or relaunch it.
Even after following the above-mentioned steps, if you see the error: invalid active developer path (/Library/Developer/CommandLineTools). The next step would be to try and install Command Line Tools using a DMG file that can be downloaded directly from the Apple website.
Again, if you are using Homebrew, you need to update it. You don’t need to uninstall and again install Homebrew on Mac.
NOTE: If you are using Homebrew, try updating it after re-installing Command Line tools.
Credits: Git not working after macOS Update
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:
I completely uninstalled the outdated XCode
I reinstalled the most recent XCode from the app store
That was all. Git was restored.
https://i.stack.imgur.com/FZZFO.png
For those using Catalina and Xcode-beta:
sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer
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
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.
I updated my macOS yesterday,from macOS Mojave(10.14.6)to macOS Catalina(10.15.7),I was executing "git" command in my project. I get same errors。
run:
xcode-select --install
After Updating macOS to Monterey (12.3) from BigSur getting such issue
only worked-
xcode-select --install
Done!
MacOS :Monterey Year: 2022
Solution: Upgrade to 12.2.1 or later
I upgraded to Monetery 12.2 as my Macbook pro got replaced. Ran into same issue as OP:
Git is not working after macOS Update (Xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)
One would think that by this time Apple would have added xCode & developer tools into OS main build. Turned out they did. I had to upgrade to 12.2.1, which included "command line tools for xCode". I still need to do step upgrade to 12.4 , but I believe we finally have these tools as part of OS build.
Here's screen-shot while attempting to upgrade from 12.2.1 to 12.3.1 (I forgot to take one while upgrading from 12.2 to 12.2.1, but I am pretty sure it had same Addons)
https://i.stack.imgur.com/UrqeV.png
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
Edge case, but still worth writing down: when migrating from and older Mac with Migration Assistant, you may have selected the option to transfer all your applications from your older Mac. Applications, like Xcode needs to be updated if it was transferred and preserved OR delete from your other user's Applications folder. This is because Xcode has not been set up properly after the first start with the new OS version.
None of the above answers worked for me. I had a couple of issues. First, I installed the latest version of Xcode, 14.0 beta. That ended up not working because it was a version that is not compatible with Monterey. And my computer is too old to install Ventura beta. So I had to go and find out which version of Xcode actually did work. And that ended up being 13.4.1. So I installed that. I had taken all the right steps beforehand to delete the old version, and then placed the new one, as always, into my Applications folder. But for whatever reason, it did not end up there. When I checked to see if my install was successful, errors were thrown in Terminal. I had also previously updated CLT, which included the correct version. However, Terminal returned that I needed to install CLT. And when I tried, it told me that it was already installed, but I should change the path of my Xcode or install CLT (which obviously was not a real option). I found the solution in this article entitled Xcode-select active developer directory error. And I ran the following command in Terminal which fixed my path:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Hope this helps anyone else who encounters the same issue when trying to update Xcode on macOS Monterey and also can't update to macOS Ventura.
Success story sharing
xcode-select --install
. Then it'll work.