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

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 answer is

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:


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

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

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

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:

  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

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 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

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.

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

if you get Software Update server issue: enter image description here

use with sudo:

sudo xcode-select --install

Questions with xcode tag:

Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64 iPhone is not available. Please reconnect the device Make a VStack fill the width of the screen in SwiftUI error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65 The iOS Simulator deployment targets is set to 7.0, but the range of supported deployment target version for this platform is 8.0 to 12.1 Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Xcode 10: A valid provisioning profile for this executable was not found Xcode 10, Command CodeSign failed with a nonzero exit code Problems after upgrading to Xcode 10: Build input file cannot be found Command CompileSwift failed with a nonzero exit code in Xcode 10 Xcode couldn't find any provisioning profiles matching Distribution certificate / private key not installed Codesign wants to access key "access" in your keychain, I put in my login password but keeps asking me Build fails with "Command failed with a nonzero exit code" Error ITMS-90717: "Invalid App Store Icon" Xcode 9 Swift Language Version (SWIFT_VERSION) Fixing Xcode 9 issue: "iPhone is busy: Preparing debugger support for iPhone" Xcode 9 error: "iPhone has denied the launch request" Download & Install Xcode version without Premium Developer Account How do you perform wireless debugging in Xcode 9 with iOS 11, Apple TV 4K, etc? Xcode Error: "The app ID cannot be registered to your development team." Linker Command failed with exit code 1 (use -v to see invocation), Xcode 8, Swift 3 How to update the constant height constraint of a UIView programmatically? How can I regenerate ios folder in React Native project? `React/RCTBridgeModule.h` file not found I get conflicting provisioning settings error when I try to archive to submit an iOS app Xcode: Could not locate device support files Failed to create provisioning profile Xcode error: Code signing is required for product type 'Application' in SDK 'iOS 10.0' Updating to latest version of CocoaPods? Swift 3 - Comparing Date objects How to make a simple rounded button in Storyboard? How to program a delay in Swift 3 How can I delete derived data in Xcode 8? Code signing is required for product type 'Application' in SDK 'iOS 10.0' - StickerPackExtension requires a development team error Hide strange unwanted Xcode logs Certificate has either expired or has been revoked Missing Compliance in Status when I add built for internal testing in Test Flight.How to solve? This action could not be completed. Try Again (-22421) This certificate has an invalid issuer Apple Push Services How to update Xcode from command line Xcode 7.2 no matching provisioning profiles found MacOS Xcode CoreSimulator folder very big. Is it ok to delete content? How do I completely rename an Xcode project (i.e. inclusive of folders)? "Could not find Developer Disk Image" Xcode 7 error: "Missing iOS Distribution signing identity for ..." Reason: no suitable image found 'Framework not found' in Xcode

Questions with git tag:

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio? How to know the git username and email saved during configuration? How to add a new project to Github using VS Code git clone error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054 fatal: ambiguous argument 'origin': unknown revision or path not in the working tree HTTP Basic: Access denied fatal: Authentication failed npm notice created a lockfile as package-lock.json. You should commit this file Do I commit the package-lock.json file created by npm 5? Abort a Git Merge key_load_public: invalid format git - remote add origin vs remote set-url origin Visual Studio 2017 - Git failed with a fatal error Get git branch name in Jenkins Pipeline/Jenkinsfile Changing the git user inside Visual Studio Code How to compare different branches in Visual Studio Code Git checkout - switching back to HEAD Clear git local cache Deleting a local branch with Git Rebuild Docker container on file changes Cloning specific branch How to add chmod permissions to file in Git? Git copy changes from one branch to another Git merge with force overwrite Project vs Repository in GitHub How to add a file to the last commit in git? Getting permission denied (public key) on gitlab Delete commit on gitlab gpg failed to sign the data fatal: failed to write commit object [Git 2.10.0] Remove a modified file from pull request Updates were rejected because the tip of your current branch is behind its remote counterpart Can't push to the heroku How to discard local changes and pull latest from GitHub repository In Visual Studio Code How do I merge between two local branches? error: RPC failed; curl transfer closed with outstanding read data remaining Change drive in git bash for windows Checkout Jenkins Pipeline Git SCM with credentials? How to fix git error: RPC failed; curl 56 GnuTLS Trying to pull files from my Github repository: "refusing to merge unrelated histories" Visual Studio Code how to resolve merge conflicts with git? merge one local branch into another local branch Can't push to remote branch, cannot be resolved to branch

Questions with macos tag:

Problems with installation of Google App Engine SDK for php in OS X dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac Could not install packages due to an EnvironmentError: [Errno 13] How do I install Java on Mac OSX allowing version switching? Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Can't compile C program on a Mac after upgrade to Mojave You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user) How can I install a previous version of Python 3 in macOS using homebrew? Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'" Cannot connect to the Docker daemon on macOS Stuck at ".android/repositories.cfg could not be loaded." How to switch Python versions in Terminal? Class JavaLaunchHelper is implemented in two places How can I add a .npmrc file? "SSL certificate verify failed" using pip to install packages How to uninstall Anaconda completely from macOS mysqli_real_connect(): (HY000/2002): No such file or directory How do I upgrade to Python 3.6 with conda? pip or pip3 to install packages for Python 3? Brew install docker does not include docker engine? Homebrew refusing to link OpenSSL How to install JQ on Mac by command-line? How to update Ruby with Homebrew? psql: command not found Mac macOS on VMware doesn't recognize iOS device Is there a keyboard shortcut (hotkey) to open Terminal in macOS? pip installs packages successfully, but executables not found from command line SSL: CERTIFICATE_VERIFY_FAILED with Python3 Eclipse not recognizing JVM 1.8 How to install latest version of openssl Mac OS X El Capitan How can I easily switch between PHP versions on Mac OSX? Switch between python 2.7 and python 3.5 on Mac OS X Finding Android SDK on Mac and adding to PATH How to install wget in macOS? Reset MySQL root password using ALTER USER statement after install on Mac `node-pre-gyp install --fallback-to-build` failed during MeanJS installation on OSX MacOS Xcode CoreSimulator folder very big. Is it ok to delete content? Mysql password expired. Can't connect What version of Python is on my Mac? How to install gdb (debugger) in Mac OSX El Capitan? Command Line Tools not working - OS X El Capitan, Sierra, High Sierra, Mojave Operation Not Permitted when on root - El Capitan (rootless disabled) How to run C program on Mac OS X using Terminal? How to install sshpass on mac? Can't install gems on OS X "El Capitan" "OSError: [Errno 1] Operation not permitted" when installing Scrapy in OSX 10.11 (El Capitan) (System Integrity Protection) Can you install and run apps built on the .NET framework on a Mac? Pyspark: Exception: Java gateway process exited before sending the driver its port number pip installation /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory

Questions with command-line tag:

Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Flutter command not found Angular - ng: command not found how to run python files in windows command prompt? How to run .NET Core console app from the command line Copy Paste in Bash on Ubuntu on Windows How to find which version of TensorFlow is installed in my system? How to install JQ on Mac by command-line? Python not working in the command line of git bash Run function in script from command line (Node JS) How can I pass variable to ansible playbook in the command line? Postgres "psql not recognized as an internal or external command" How to call VS Code Editor from terminal / command line 7-Zip command to create and extract a password-protected ZIP file on Windows? List file using ls command in Linux with full path Find Process Name by its Process ID How to resolve "gpg: command not found" error during RVM installation? How to run .sh on Windows Command Prompt? maven command line how to point to a specific settings.xml for a single command? Run Executable from Powershell script with parameters Running CMD command in PowerShell Command Prompt Error 'C:\Program' is not recognized as an internal or external command, operable program or batch file Build Android Studio app via command line 'ssh' is not recognized as an internal or external command Input from the keyboard in command line application How to force 'cp' to overwrite directory instead of creating another one inside? Use Robocopy to copy only changed files? Change mysql user password using command line mkdir's "-p" option Shell Script: How to write a string to file and to stdout on console? Enter export password to generate a P12 certificate Launch Pycharm from command line (terminal) Difference between IISRESET and IIS Stop-Start command How can I find out if I have Xcode commandline tools installed? Increment variable value by 1 ( shell programming) phpmyadmin #1045 Cannot log in to the MySQL server. after installing mysql command line client Number of processors/cores in command line How to merge 2 JSON objects from 2 files using jq? Displaying output of a remote command with Ansible How do I restart nginx only after the configuration test was successful on Ubuntu? How can I get the current date and time in the terminal and set a custom command in the terminal for it? Run a JAR file from the command line and specify classpath Run R script from command line How to zip a file using cmd line? How to switch between python 2.7 to python 3 from command line? One command to create a directory and file inside it linux command How to find the mysql data directory from command line in windows Execute a command in command prompt using excel VBA how to change directory using Windows command line How do I import an SQL file using the command line in MySQL?

Questions with terminal tag:

Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Can't compile C program on a Mac after upgrade to Mojave Flutter command not found VSCode Change Default Terminal How to switch Python versions in Terminal? How to open the terminal in Atom? Color theme for VS Code integrated terminal How to edit a text file in my terminal How to open google chrome from terminal? Switch between python 2.7 and python 3.5 on Mac OS X Docker-Compose can't connect to Docker Daemon npm install -g less does not work: EACCES: permission denied Ubuntu: Using curl to download an image gcloud command not found - while installing Google Cloud SDK How do I install command line MySQL client on mac? How do I see which version of Swift I'm using? How do I edit $PATH (.bash_profile) on OSX? Run / Open VSCode from Mac Terminal How to call VS Code Editor from terminal / command line OS X Terminal shortcut: Jump to beginning/end of line How to fix request failed on channel 0 Error: Could not create the Java Virtual Machine Mac OSX Mavericks Gulp command not found after install Keep SSH session alive curl: (6) Could not resolve host: google.com; Name or service not known Reusing output from last command in Bash How to Batch Rename Files in a macOS Terminal? Failed to build gem native extension (installing Compass) "You have mail" message in terminal, os X How do I pause my shell script for a second before continuing? How to run Python script on terminal? mvn command not found in OSX Mavrerick How do I force detach Screen from another SSH session? How to run mysql command on bash? Change working directory in my current shell context when running Node script Why is the apt-get function not working in the terminal on Mac OS X v10.9 (Mavericks)? Connect with SSH through a proxy OS X cp command in Terminal - No such file or directory How to run ~/.bash_profile in mac terminal Change all files and folders permissions of a directory to 644/755 How can I get the current date and time in the terminal and set a custom command in the terminal for it? Kill python interpeter in linux from the terminal Why does configure say no C compiler found when GCC is installed? -bash: export: `=': not a valid identifier How to terminate process from Python using pid? Display current path in terminal only Failed to add the host to the list of know hosts How do I update zsh to the latest version? How to edit/save a file through Ubuntu Terminal Alternative Windows shells, besides CMD.EXE?