2339

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?

MaxiGui
  • 4,537
  • 4
  • 9
  • 31
dustbuster
  • 55,449
  • 4
  • 9
  • 31
  • 3
    This is more of a git problem than a macOS problem. – dustbuster Jan 14 '19 at 06:17
  • 4
    Possible duplicate https://apple.stackexchange.com/questions/254380/why-am-i-getting-an-invalid-active-developer-path-when-attempting-to-use-git-a – markroxor Jul 01 '19 at 05:28
  • 21
    to be honest, this problem is something APPLE should take care of. They create it, they should fix it !!!!! Asking everyone to run that command everytime this happens isn't an Good/Correct option. Not to mention you need to download that big chunk for git only. – windmaomao Feb 04 '21 at 14:30
  • 2
    I didn’t run into it on my update to Big Sur. Only had this problem the year when I originally wrote this Q&A. I’ve just been updating it every year to include the latest changes. – dustbuster Feb 05 '21 at 05:07
  • If you don't have Xcode, only installing Xcode command line tools will solve the problem. https://developer.apple.com/download/more/?=command%20line%20tools – alianjum0 Feb 08 '21 at 09:18
  • alianjum0, thanks for that. I just went down a huge rat hole being unable to install XCode from the AppStore (long story). Being able to install just the CLI saved the day! – Roy Smith Mar 13 '21 at 02:02
  • 2
    We should get paid by apple for debugging their code! – Nir Apr 01 '21 at 09:46
  • It's a failure to completely update ALL their software during a major version update. I have not run into this since i initially made the question and answer! So it works on some level i suppose! – dustbuster Apr 01 '21 at 13:33

24 Answers24

3804

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.

image of apple developer page and dmg for DL

dustbuster
  • 55,449
  • 4
  • 9
  • 31
  • 57
    This fixed the issue I had with Microsoft Visual Studio Code which was complaining about Git not being installed when I first launched it after upgrading to Mojave. I thought the issue was VS Code, but it was the issue in this SO question. Restarting VS Code after installing the Xcode Command-line Tools solved the issue. – Mark Oct 10 '18 at 00:36
  • 270
    I wish the Xcode update was part of the OS update. Something like this happens every time I upgrade. Annoying. – mvndaai Dec 14 '18 at 17:17
  • It's happened to me on every update. I guess the majority of Mac users don't have Xcode installed! Otherwise apple probably would update it at the same time. . – dustbuster Dec 14 '18 at 18:19
  • 14
    Definitely annoying though. A simple check for Xcode installation and then an update during the OS update would be pretty simple to add. It's always something with these OS updates from Apple. You'd think they'd have figured it out by now. – zgr024 Dec 14 '18 at 20:53
  • 2
    In case you installed GIT and this is still not working you might need to add an alias: `sudo xcode-select -s /Library/Developer/CommandLineTools` – Miguel Garrido Dec 30 '18 at 16:52
  • 2
    I'd already visited the App Store, and it claimed to find no updates. Why can't it recognize that Xcode needs to be updated? – Jim Van Zandt Jan 28 '19 at 13:16
  • 18
    For anyone using Git in PHPStorm; you need to restart PHPStorm after running `xcode-select --install`. Then it'll work. – Daan van den Bergh Feb 13 '19 at 07:20
  • Same SVN issue got fixed by this method as well. – yantaq May 14 '19 at 17:27
  • When I go to install (after agreeing to T's & C's) I get "Can't install the software because it is not currently available from th Software Update server." Has anyone else gotten this? – James Jun 06 '19 at 12:52
  • I did not need to restart my terminal btw. – SuryaVal Jun 07 '19 at 16:38
  • Nothing is working for me. I am using Sourcetree on same repository. it shows the username and email correctly. – ashishn Jun 15 '19 at 07:33
  • For me running `open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg` after the `xcode-select --install` command worked, following [this stackoverflow answer](https://stackoverflow.com/questions/52509602/cant-compile-c-program-on-a-mac-after-upgrade-to-mojave) – Forcetti Aug 27 '19 at 18:23
  • 69
    This solution works for me for Mac Catalina update also. Superb!!! – Shahnaz Khan Oct 08 '19 at 16:55
  • I updated the text to just say "MacOs update" I am very happy it works for Catalina! Figured it would! – dustbuster Oct 10 '19 at 01:30
  • just wanted to add that you need to restart the computer, also a good `brew doctor` may also help find any issues – luis19mx Nov 14 '19 at 16:27
  • I am using android studio on Mac, recently updated OS to Catalina. After updating OS, stop connecting to Version Control (subversion). But thanks to @dustbuster, installing xCode solve the my problem. – Hiren Dabhi Nov 23 '19 at 10:54
  • But why ? Why do we need to do this ? my question is to Apple falks – Ugur Kazdal Dec 19 '19 at 10:48
  • Should I do the same with zsh too ? – Tilak Maddy Dec 23 '19 at 08:40
  • You will not have to do anything to zsh Tilak. The issue is git. Not zsh. – dustbuster Dec 23 '19 at 18:05
  • After the update , you need to make sure to restart all the applications and IDE that depend or have connection with git like all IntelliJ IDEs ,sublime with git , source tree etc to make it run properly, – Taher Khalil Dec 25 '19 at 11:30
  • 2
    If you have Xcode installed, you **do not need the separate command line tools install**. Just make sure you run `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. – uliwitness Feb 15 '20 at 10:50
  • _July 2020 Update_: This answer worked for me on Mac OS Mojave (after upgrading from El Captain). Takes a while to install though. (Just doing `xcode-select --reset` as mentioned in other answers did not work for me) – Anupam Jul 07 '20 at 07:38
  • 1
    You saved my day!! Awesome. Maven started working after this. – Vishrant Oct 21 '20 at 05:38
  • 1
    @Vishrant I am just happy I could contribute to the interwebs! You are quite welcome! – dustbuster Oct 21 '20 at 15:24
  • The way apple manages the xcode downloads has changed. I actually ran into this myself AGAIN when i upgraded this year! So i updated the answer not too long ago. – dustbuster Oct 22 '20 at 18:26
  • For PyCharm also need to do like PHPStorm as suggested by @DaanvandenBergh . That is need to restart PyCharm after running `xcode-select --install` – Md. Abu Nafee Ibna Zahid Nov 08 '20 at 06:42
  • 1
    Upgraded to macOS Big Sur and here it is again. – larrydalmeida Nov 17 '20 at 10:40
  • 1
    I have updated this answer every year! Check out solution #2, that's probably the most relevant. There's a surge this time every year! – dustbuster Nov 17 '20 at 16:49
  • 1
    I had to download `Command_Line_Tools_for_Xcode_12.3_beta.dmg` for MacOS 11.1 Big Sur. Then it worked perfectly. – herrsch Nov 24 '20 at 09:26
  • Glad to hear! I have not updated yet. is that the name of the download file now? – dustbuster Nov 30 '20 at 19:52
  • 1
    thanks a lot! I immediately went for solution 2 once I read that solution 1 might very well fail haha. – Emile Beukes Jan 05 '21 at 10:42
  • Most Excellent! I actually didn't run into it this time around when I updated to Big Sur. – dustbuster Jan 05 '21 at 19:39
  • 1
    every freaking update the same thing happens... – Fabio Reis Feb 04 '21 at 03:35
  • How could Git is not part of OSX? If not, then make it never part of OSX? what's the benefits of bundling a developer tool in the operation system which is not responsible for updating it? – windmaomao Feb 04 '21 at 14:29
  • Solution #1 worked for me. – Indika K Feb 14 '21 at 00:07
  • Awesome! Solution #1 works for me. Thanks :) It's so annoying to do this after every minor update. Techies at Apple Listen O Listen !! – Anand Mar 14 '21 at 15:06
  • 1
    You should not have to do it after every update, that is annoying!! – dustbuster Mar 15 '21 at 12:07
  • I update Xcode to Version 12.5 (12E262), which is the latest one. And I get this same error. Does it means I need to do `xcode-select --install` each time manually? – ChuckZHB Apr 30 '21 at 10:55
  • 1
    `xcode-select --install` + terminal restart fixed broken git after Catalina -> Big Sure update! – pawelswiecki May 13 '21 at 12:16
184

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.

deef
  • 2,396
  • 1
  • 10
  • 17
  • 13
    This should be the right answer, tried on 3 machines and @dustbuster answer doesn't work anymore and it shows "software was unavailable from the update server when trying" – user2577923 Nov 02 '18 at 14:17
  • 6
    For me this ends with `software not available at server` but @High6's answer below works. `xcode-select --reset` – briankip Nov 04 '18 at 14:59
  • downloading ``Command Line Tools (macOS 10.14) for Xcode 10.1`` from the link. thanks! – Xavier Ojeda Aguilar Nov 04 '18 at 21:33
  • 2
    Had xcode installed still there were issues. This worked like a charm... should be the selected answer. Or should be addendum to top answer. – AmitM Nov 22 '19 at 11:43
  • 2
    This also works for macOS 10.15.2. Though I had to select `Command Line Tools for Xcode 11.3`, since Xcode 10.1 wasn't available – Rachel Lanman Dec 13 '19 at 21:04
  • On Mac OS 10.15.6 Catalina, this was the solution that worked for me. (Command Line tools for Xcode 12 if you're on Catalina - skip the mammoth Xcode 12 app download) – jkix Sep 21 '20 at 16:25
129

For me xcode-select --reset was the solution on Mojave.

H6.
  • 26,822
  • 12
  • 70
  • 78
  • 6
    somehow, "xcode-select --install" ends of software not available at server. But this one works – Yan Zhu Nov 01 '18 at 04:32
  • This worked for me, I ran this command after installed new Xcode. – Sunho Hong Sep 24 '19 at 02:01
  • 5
    I just upgraded from Mac OS X 10.14 (Mojave) to MacOS 10.15 (Catalina) and faced this problem, this solution worked fine, it was no necessary to run `xcode-select --install`. – OJVM Oct 22 '19 at 22:19
  • 2
    works for me on Catalina as well, but needed to add `sudo` – gafi Nov 06 '19 at 10:58
  • 2
    `sudo xcode-select --reset` worked for me on a Mojave --> Catalina upgrade of MacOS – Chris Gillatt Dec 12 '19 at 15:34
  • *2020 Update*: Same solution for Catalina OS – Vikram K Jun 07 '20 at 16:35
  • _July 2020 Update_: This did not work on Mac OS Mojave (after upgrading from El Captain). This worked from the accepted answer: `xcode-select --install`. Takes a while to install though – Anupam Jul 07 '20 at 07:36
  • Does not work for Catalina. `sudo xcode-select --reset` appears to do nothing. – BKE Sep 28 '20 at 07:18
  • I needed to run this command after I migrated from old Mojave MBP to new Catalina MBP and couldn't have git etc running; intellij complained – James Render Oct 09 '20 at 09:22
79

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
  • 1
    Yep same for me, @dustbuster might be a good idea to merge these answers. – James Oct 19 '18 at 19:30
  • Ok this one solved this for me. Tried `xcode-select --install` and downloading and installing manually, none of the solutions worked. Note that I waited and upgraded to version 10.14.1. – mpiktas Nov 19 '18 at 17:38
  • If you have Xcode installed, you **do not need the separate command line tools install**. Just make sure you run `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. – uliwitness Feb 15 '20 at 10:51
  • been through so many answers, this is the one that worked for me after the Mojave update, thanks! – mobcity zkore Aug 27 '20 at 23:27
70

updated from Mojave to Big Sur and got the same error : the command

xcode-select --install

worked like a charm

47

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.

J P
  • 3,692
  • 2
  • 27
  • 37
briankip
  • 2,138
  • 2
  • 21
  • 24
  • your solution worked for me on MacOS 10.13 High Sierra. Thank you. – Daniel Jan 01 '20 at 19:46
  • If you **have Xcode installed**, this is the correct solution. 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. – uliwitness Feb 15 '20 at 10:54
46

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)

Ryan Stewart
  • 583
  • 5
  • 5
  • If you have Xcode installed, you **do not need the separate command line tools install**. Just make sure you run `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. – uliwitness Feb 15 '20 at 10:52
45

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

Muhammad Soliman
  • 14,761
  • 4
  • 84
  • 60
  • If you have Xcode installed, you **do not need the separate command line tools install**. Just make sure you run `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. – uliwitness Feb 15 '20 at 10:58
  • Xcode select did it since I only had the beta version installed! – gurehbgui Aug 09 '20 at 18:00
44

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

enter image description here

taha
  • 671
  • 6
  • 5
  • This fixes a couple items, but not all – Murwa Aug 13 '19 at 18:20
  • I had Xcode 10.3, 11.1 and 11.2 and Xcode wasn't able to figure out which version to use for the Command Line Tools and left the dropdown with empty. Once 11.1 was selected for my purpose, git commands started to work. – Chandana Kithalagama Nov 18 '19 at 23:34
  • This popup is equivalent to calling `xcode-select --switch` with the path to the Xcode package of whatever version you select here, by the way. – uliwitness Feb 15 '20 at 10:55
  • Good hint thank you , Whatever the way , the important thing is to solve the issue – taha Apr 06 '20 at 13:54
  • This works for me.. Thanks a lot. I was having old and new version of Xcode at different locations. – iGW Apr 13 '20 at 10:35
  • This worked for me. – kalpa Dec 25 '20 at 11:02
33

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.

Cœur
  • 32,421
  • 21
  • 173
  • 232
P. Hurme
  • 339
  • 2
  • 2
  • 1
    If you have Xcode installed, you **do not need the separate command line tools install**. Just make sure you run `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. – uliwitness Feb 15 '20 at 10:53
32

Mac OS : Big Sur

First Priority

sudo xcode-select --reset

sudo xcodebuild -license

Second Priority

xcode-select --install
Anand Khanpara
  • 502
  • 4
  • 8
30

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
ras
  • 419
  • 5
  • 6
27

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
Selim Reza
  • 625
  • 8
  • 21
  • If you have Xcode installed, you **do not need the separate command line tools install**. Just make sure you run `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. – uliwitness Feb 15 '20 at 10:56
  • Also, it makes no sense to do both calls to `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. – uliwitness Feb 15 '20 at 10:57
26

If you have Xcode downloaded manually (i.e. not from the App Store) or don't have Xcode at all:

  1. sudo rm -rf /Library/Developer/CommandLineTools
  2. Go to https://developer.apple.com/download/more/ to download Command Line Tools (macOS 10.14) for Xcode 10
  3. Setup Command Line Tools

If you have Xcode installed from the App Store:

  1. xcode-select --install
Şafak Gezer
  • 3,389
  • 3
  • 37
  • 44
  • I want to install Command Line Tools only and Not Xcode. This solution seems to be the best. Minimal install – mythicalcoder Jul 18 '19 at 17:34
  • Perfect for me since I don't need Xcode but I do need Git :) – Ryan Amaral Jan 22 '20 at 12:37
  • After I installed Catalina and trying the `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.) – vincentmajor Sep 27 '20 at 21:11
25

If you use xcode then install it (~12GB)

xcode-select --install

Otherwise install latest command line tools (~500MB)

Downloads

Chenna
  • 1,561
  • 2
  • 18
  • 30
6

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.

kiko carisse
  • 986
  • 11
  • 17
6

This works for me

sudo xcode-select --reset 
sudo xcodebuild -license

X-code must be installed.

Daniel
  • 61
  • 1
  • 1
5

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.
muru
  • 4,232
  • 30
  • 69
Caleb Mbakwe
  • 119
  • 1
  • 5
5

I observed in the Catalina privacy setting if Xcode not added in Full access disk I will get the same error, Xcode does not run scripts. Add your Xcode the same as in the attached image. After that clean build and run. Hope so it will work. Security & Privacy

Shauket Sheikh
  • 2,159
  • 14
  • 31
3

For those using Catalina and Xcode-beta:

sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer
Destry
  • 71
  • 1
  • 5
3

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

hitesh
  • 368
  • 3
  • 12
2

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.

prime
  • 11,246
  • 11
  • 75
  • 112
0

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
Bagata
  • 1,959
  • 4
  • 26
  • 36
0

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.