Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)

1,095,076

Solution 1

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.

image of apple developer page and dmg for DL

Solution 2

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.

Solution 3

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

Solution 4

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

Solution 5

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

xcode-select --install

worked like a charm

Share:
1,095,076
dustbuster
Author by

dustbuster

I enjoy hunting bugs, making code more efficient, trouble shooting difficult problems, and long walks on the beach. I've been in php frameworks the past few years, including Magento and Laravel. But I've also worked in VBScript and Cold Fusion over the last decade as well. I'm also writing frontend Vue these days as well. I am also a father of 3, a husband, my other interests are the fitness (mountain biking, weight training) gaming, some Djing here and there, and just spending time with the fam-fam. I get stoked on life!! There's a lot of very smart people here on the Stack, and I am happy to be a part of such a large community trying to make developers lives easier.

Updated on July 10, 2022

Comments

  • dustbuster
    dustbuster almost 2 years

    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?

    • dustbuster
      dustbuster over 5 years
      This is more of a git problem than a macOS problem.
    • markroxor
      markroxor almost 5 years
    • windmaomao
      windmaomao over 3 years
      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.
    • dustbuster
      dustbuster over 3 years
      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.
    • alianjum0
      alianjum0 over 3 years
      If you don't have Xcode, only installing Xcode command line tools will solve the problem. developer.apple.com/download/more/?=command%20line%20tools
    • Roy Smith
      Roy Smith about 3 years
      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!
    • Nir
      Nir about 3 years
      We should get paid by apple for debugging their code!
    • dustbuster
      dustbuster about 3 years
      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!
    • Pryftan
      Pryftan over 2 years
      @dustbuster No. It's not a problem with git. It's a macOS problem. You get the same error from other commands like make. The solution is what I thought it was but I checked here anyway as I wanted to be sure - too much going on to worry about possible fixes.
    • Vaulstein
      Vaulstein over 2 years
      Another OS update and yet 3 years later, issue still exist.
    • thisisshantzz
      thisisshantzz over 2 years
      I updated to Monterey and faced the same issue. Apple really needs to look into this issue.
    • iamnicoj
      iamnicoj over 2 years
      I never had this issue before and I've been using macOS since about the last 3 years. However I just updated it to Monterrey and it broke git.
    • Derek Greer
      Derek Greer over 2 years
      "This is more of a git problem ..." how so? git is merely a command line tool. I've used git on other platforms for decades and have never encountered this issue until working on a Mac. What the hell does git have to do with XCode?
    • dustbuster
      dustbuster over 2 years
      I wrote that 3 years ago matey! lol But yea. it's totally a macOs problem. I did not think this would be a relevant for 3 years!
    • rkechols
      rkechols over 2 years
      Is there some issue/ticket in an Apple help system that we can upvote to try to get more attention on this?
    • Kamlesh
      Kamlesh over 2 years
      No need to download Xcode. I am using MacOS Monterey version 12.x. I have downloaded "Command Line Tools for Xcode 13.3 beta". Restarted terminal and command line is working along with github clone/pull/push issues. It worked like charm.
  • Mark
    Mark over 5 years
    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.
  • James
    James over 5 years
    Yep same for me, @dustbuster might be a good idea to merge these answers.
  • Yan Zhu
    Yan Zhu over 5 years
    somehow, "xcode-select --install" ends of software not available at server. But this one works
  • user2577923
    user2577923 over 5 years
    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"
  • briankip
    briankip over 5 years
    For me this ends with software not available at server but @High6's answer below works. xcode-select --reset
  • Xavier Ojeda Aguilar
    Xavier Ojeda Aguilar over 5 years
    downloading Command Line Tools (macOS 10.14) for Xcode 10.1 from the link. thanks!
  • mpiktas
    mpiktas over 5 years
    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.
  • mvndaai
    mvndaai over 5 years
    I wish the Xcode update was part of the OS update. Something like this happens every time I upgrade. Annoying.
  • dustbuster
    dustbuster over 5 years
    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. .
  • zgr024
    zgr024 over 5 years
    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.
  • Miguel Garrido
    Miguel Garrido over 5 years
    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
  • Jim Van Zandt
    Jim Van Zandt over 5 years
    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?
  • Daan van den Bergh
    Daan van den Bergh about 5 years
    For anyone using Git in PHPStorm; you need to restart PHPStorm after running xcode-select --install. Then it'll work.
  • yantaq
    yantaq almost 5 years
    Same SVN issue got fixed by this method as well.
  • James
    James almost 5 years
    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?
  • SuryaVal
    SuryaVal almost 5 years
    I did not need to restart my terminal btw.
  • ashishn
    ashishn almost 5 years
    Nothing is working for me. I am using Sourcetree on same repository. it shows the username and email correctly.
  • mythicalcoder
    mythicalcoder almost 5 years
    I want to install Command Line Tools only and Not Xcode. This solution seems to be the best. Minimal install
  • Murwa
    Murwa over 4 years
    This fixes a couple items, but not all
  • Forcetti
    Forcetti over 4 years
    For me running open /Library/Developer/CommandLineTools/Packages/macOS_SDK_heade‌​rs_for_macOS_10.14.p‌​kg after the xcode-select --install command worked, following this stackoverflow answer
  • Sunho Hong
    Sunho Hong over 4 years
    This worked for me, I ran this command after installed new Xcode.
  • Shahnaz Khan
    Shahnaz Khan over 4 years
    This solution works for me for Mac Catalina update also. Superb!!!
  • dustbuster
    dustbuster over 4 years
    I updated the text to just say "MacOs update" I am very happy it works for Catalina! Figured it would!
  • OJVM
    OJVM over 4 years
    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.
  • gafi
    gafi over 4 years
    works for me on Catalina as well, but needed to add sudo
  • luis19mx
    luis19mx over 4 years
    just wanted to add that you need to restart the computer, also a good brew doctor may also help find any issues
  • Chandana Kithalagama
    Chandana Kithalagama over 4 years
    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.
  • AmitM
    AmitM over 4 years
    Had xcode installed still there were issues. This worked like a charm... should be the selected answer. Or should be addendum to top answer.
  • Hiren Dabhi
    Hiren Dabhi over 4 years
    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.
  • Chris Gillatt
    Chris Gillatt over 4 years
    sudo xcode-select --reset worked for me on a Mojave --> Catalina upgrade of MacOS
  • Rachel Lanman
    Rachel Lanman over 4 years
    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
  • Ugur Kazdal
    Ugur Kazdal over 4 years
    But why ? Why do we need to do this ? my question is to Apple falks
  • Tilak Madichetti
    Tilak Madichetti over 4 years
    Should I do the same with zsh too ?
  • dustbuster
    dustbuster over 4 years
    You will not have to do anything to zsh Tilak. The issue is git. Not zsh.
  • Taher Khalil
    Taher Khalil over 4 years
    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,
  • Daniel
    Daniel over 4 years
    your solution worked for me on MacOS 10.13 High Sierra. Thank you.
  • Ryan Amaral
    Ryan Amaral over 4 years
    Perfect for me since I don't need Xcode but I do need Git :)
  • uliwitness
    uliwitness about 4 years
    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
    uliwitness about 4 years
    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
    uliwitness about 4 years
    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
    uliwitness about 4 years
    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
    uliwitness about 4 years
    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
    uliwitness about 4 years
    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
    uliwitness about 4 years
    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
    uliwitness about 4 years
    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
    uliwitness about 4 years
    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.
  • taha
    taha about 4 years
    Good hint thank you , Whatever the way , the important thing is to solve the issue
  • iGW
    iGW about 4 years
    This works for me.. Thanks a lot. I was having old and new version of Xcode at different locations.
  • Vikram K
    Vikram K almost 4 years
    2020 Update: Same solution for Catalina OS
  • Anupam
    Anupam almost 4 years
    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
    Anupam almost 4 years
    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)
  • gurehbgui
    gurehbgui almost 4 years
    Xcode select did it since I only had the beta version installed!
  • mobcity zkore
    mobcity zkore over 3 years
    been through so many answers, this is the one that worked for me after the Mojave update, thanks!
  • jkix
    jkix over 3 years
    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)
  • vincentmajor
    vincentmajor over 3 years
    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.)
  • BKE
    BKE over 3 years
    Does not work for Catalina. sudo xcode-select --reset appears to do nothing.
  • James Render
    James Render over 3 years
    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
  • Vishrant
    Vishrant over 3 years
    You saved my day!! Awesome. Maven started working after this.
  • dustbuster
    dustbuster over 3 years
    @Vishrant I am just happy I could contribute to the interwebs! You are quite welcome!
  • dustbuster
    dustbuster over 3 years
    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.
  • Md. Abu Nafee Ibna Zahid
    Md. Abu Nafee Ibna Zahid over 3 years
    For PyCharm also need to do like PHPStorm as suggested by @DaanvandenBergh . That is need to restart PyCharm after running xcode-select --install
  • larrydalmeida
    larrydalmeida over 3 years
    Upgraded to macOS Big Sur and here it is again.
  • dustbuster
    dustbuster over 3 years
    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!
  • geekhunger
    geekhunger over 3 years
    I had to download Command_Line_Tools_for_Xcode_12.3_beta.dmg for MacOS 11.1 Big Sur. Then it worked perfectly.
  • dustbuster
    dustbuster over 3 years
    Glad to hear! I have not updated yet. is that the name of the download file now?
  • Ling Vu
    Ling Vu over 3 years
    Best answer for Big Sur
  • Manish
    Manish over 3 years
    For big Sur, this first priority is usefull. Thanks for saving lot of time and Data.
  • Ali Qaderi
    Ali Qaderi over 3 years
    I am using Big Sur (xcode-select --install) helped me.
  • Emile Beukes
    Emile Beukes over 3 years
    thanks a lot! I immediately went for solution 2 once I read that solution 1 might very well fail haha.
  • dustbuster
    dustbuster over 3 years
    Most Excellent! I actually didn't run into it this time around when I updated to Big Sur.
  • windmaomao
    windmaomao over 3 years
    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?
  • Romain TAILLANDIER
    Romain TAILLANDIER about 3 years
    Work for me on catalina
  • Anand
    Anand about 3 years
    Awesome! Solution #1 works for me. Thanks :) It's so annoying to do this after every minor update. Techies at Apple Listen O Listen !!
  • dustbuster
    dustbuster about 3 years
    You should not have to do it after every update, that is annoying!!
  • MMK
    MMK about 3 years
    best answer! This issue doesn’t require installation of the tool again
  • ChuckZHB
    ChuckZHB about 3 years
    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?
  • AnandShiva
    AnandShiva almost 3 years
    According to the XCode man pages(Yea they do have documentation!!!) ``` -r, --reset Unsets any user-specified developer directory, so that the developer directory will be found via the default search mecha- nism. This command must be run with superuser permissions (see sudo(8)), and will affect all users on the system. ```
  • pawelswiecki
    pawelswiecki almost 3 years
    xcode-select --install + terminal restart fixed broken git after Catalina -> Big Sure update!
  • Cameron Hudson
    Cameron Hudson almost 3 years
    I've (re)installed xcode so many times over the past 2 years that it's like "How many times do I have to teach you this lesson, old man?"
  • newbie
    newbie almost 3 years
    Thanks - worked for me! Why do MacOS upgrades always break dev tools? Disincentivizes upgrading since this is my dev laptop.
  • newbie
    newbie almost 3 years
    Thanks - worked for me! Why do MacOS upgrades always break dev tools? Disincentivizes upgrading since this is my dev laptop.
  • pasha.zhukov
    pasha.zhukov almost 3 years
    Smells like Microsoft developers injection
  • jacksonbenete
    jacksonbenete almost 3 years
    This is working for BigSur as well as the Monterey beta branch. Way easier than downloading and installing giant new Xcode releases each time you update.
  • MT_Shikomba
    MT_Shikomba almost 3 years
    Thanks, solution #1 worked for me, am on PHPStorm.
  • Jesse
    Jesse over 2 years
    Solution 1 worked for me running macOS 11.5.1. Thank you :D
  • Purushotham Kumar
    Purushotham Kumar over 2 years
    Getting below error on BigSur ➜ ~ sudo xcodebuild -license dyld: dyld cache load error: existing shared cache in memory is not compatible dyld: Library not loaded: /System/Library/Frameworks/Foundation.framework/Versions/C/F‌​oundation Referenced from: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuil‌​d Reason: image not found xcrun: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly! xcrun: error: You can set the path to the Xcode folder using /usr/bin/xcode-select -switch
  • OneCricketeer
    OneCricketeer over 2 years
    Please don't repeat existing answers
  • wegry
    wegry over 2 years
    This did not work on Monterey.
  • shoaib30
    shoaib30 over 2 years
    3 years later, the solution still works for Monterey! thanks
  • Luan Cardoso
    Luan Cardoso over 2 years
    on the update to monterey, it worked like a charm (xcode-select --install). Thank you so much!!
  • Silvia42
    Silvia42 over 2 years
    I updated from macOS Big Sur -> macOS Monterey, Nov 01, 2021. Same problem with git: xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun. This installation solved the problem: xcode-select --install THANK YOU!!!
  • VirtualWolf
    VirtualWolf over 2 years
    This did the trick for me and fixed VSCode not finding Git after I migrated from my old iMac running Catalina to my shiny new Apple Silicon MacBook Pro running Monterey via Migration Assistant.
  • Samuel Nde
    Samuel Nde over 2 years
    I cannot believe this problem has not been solved in November 2021. Apple WTH?
  • Thomas Beauvais
    Thomas Beauvais over 2 years
    Try sudo xcode-select --reset first then --install
  • Anand
    Anand over 2 years
    Had a same problem and this works :)
  • Erich Meissner
    Erich Meissner over 2 years
    I updated recently to MacOS Monterey , and this update of xcode tools was able to fix this exact same issue. Thank you.
  • Kamlesh
    Kamlesh over 2 years
    No need to download Xcode. I am using MacOS Monterey version 12.x. I have downloaded "Command Line Tools for Xcode 13.3 beta". Restarted terminal and command line is working along with github clone/pull/push issues. It worked like charm.
  • ChrisRich
    ChrisRich about 2 years
    I never understood why XCode is required for git or why it interferes with my git installation in the first place. I tried to uninstall Xcode completely to avoid this situation, but that did not work out well
  • Eric Manley
    Eric Manley about 2 years
    For iOS Monterey, I went with 13.3.1. And git started working again.
  • Cuauhtli
    Cuauhtli about 2 years
    Update 2022: works on Darwin 21.4.0
  • alianos-
    alianos- about 2 years
    That is the same with the accepted answer, but with less information!
  • Xab Ion
    Xab Ion about 2 years
    Works perfect with macOS Catalina
  • Flavien
    Flavien about 2 years
    Wow, this is ridiculous. Why do I have to download several gigs just to use git?
  • Matt West
    Matt West almost 2 years
    My first dev job was in .Net. I remember thinking Visual Studio was huge and invasive. It's got nothing on Xcode.
  • dustbuster
    dustbuster almost 2 years
    Yep I feel the same way! I learned how to code in college using Visual Studio. Now if I accidentally double click a file that's registered to open with Xcode I go right for the force quit! Do not pass go and no 200 bucks for you!