This error occurs on macOS when the Xcode Command Line Tools are missing, corrupted, or their path is invalid. It commonly appears after a macOS update and prevents Git and other development tools from working. The fix is straightforward: reinstall or reset the Command Line Tools.
The "xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)" error indicates that macOS cannot find the Xcode Command Line Tools that Git and many other developer utilities depend on. This error typically appears when you try to run Git commands in Terminal. On macOS, Git is not a standalone installation by default. Instead, it's provided as part of Apple's Xcode Command Line Tools package, which includes Git, clang (C compiler), make, and other essential development utilities. When macOS can't locate these tools at the expected path, you'll see this error. The most common trigger for this error is a **macOS system update**. Major macOS upgrades (like updating to a new version such as Ventura, Sonoma, or Tahoe) often invalidate or remove the Command Line Tools installation, requiring you to reinstall them. This is a well-known issue that affects developers after nearly every major macOS release. The full error message typically looks like: ``` xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun ``` This affects not just Git, but also other tools like `brew`, `pip`, `make`, `gcc`, and any application that relies on the Command Line Tools.
The most common and effective fix is to install (or reinstall) the Xcode Command Line Tools. Run this command in Terminal:
xcode-select --installA dialog window will appear asking you to install the tools. Click "Install" and accept the license agreement when prompted.
Important notes:
- The dialog window may appear behind other windows - check your screen carefully
- The download is approximately 130 MB but installation may take several minutes
- You'll see a confirmation message: "xcode-select: note: install requested for command line developer tools"
After installation completes, restart your Terminal (or your IDE) and try running Git again:
git --versionIf you see a version number (e.g., "git version 2.39.2"), the installation was successful.
If the Command Line Tools are installed but Git still doesn't work, reset the developer path to its default location:
sudo xcode-select --resetYou'll be prompted to enter your administrator password.
This command resets the path that macOS uses to locate the Command Line Tools. It's particularly useful when the path has become corrupted or was pointing to a removed Xcode installation.
After running the reset, verify the path is correct:
xcode-select -pThis should output:
/Library/Developer/CommandLineToolsOr, if you have full Xcode installed:
/Applications/Xcode.app/Contents/DeveloperIf you have the full Xcode application installed, you can point the developer path to use Xcode's built-in Command Line Tools instead of the standalone package:
sudo xcode-select --switch /Applications/Xcode.app/Contents/DeveloperThis is useful when:
- You have Xcode installed but the system is trying to use standalone Command Line Tools that don't exist
- You want to use the tools bundled with Xcode
Note: You don't need the full Xcode application (which is several gigabytes) just to use Git. The standalone Command Line Tools package is sufficient for most development work.
If you want to switch back to the standalone Command Line Tools:
sudo xcode-select --switch /Library/Developer/CommandLineToolsSometimes the Command Line Tools are installed, but the license agreement needs to be accepted. This commonly happens after Xcode or macOS updates.
Option 1: Accept via command line
sudo xcodebuild -license acceptOption 2: Review and accept interactively
sudo xcodebuild -licenseThis opens the license agreement in Terminal. Scroll through by pressing Space, then type agree at the end to accept.
Note: If you see "xcode-select: error: tool 'xcodebuild' requires Xcode", this means you only have Command Line Tools installed (not full Xcode), and the license acceptance isn't needed for your setup.
If xcode-select --install fails with "Software not found on server" or other errors, download the tools directly from Apple:
1. Go to https://developer.apple.com/download/more/ (Apple Developer Downloads)
2. Sign in with your Apple ID (you may need to complete two-factor authentication)
3. Search for "Command Line Tools for Xcode"
4. Download the version matching your macOS version:
- For macOS Tahoe (15.x): Command Line Tools for Xcode 16.x
- For macOS Sonoma (14.x): Command Line Tools for Xcode 15.x
- For macOS Ventura (13.x): Command Line Tools for Xcode 14.x
5. Open the downloaded .dmg file and run the installer
6. Restart your computer after installation
Important: A restart is often required when installing via the manual download method.
To check your macOS version:
sw_vers -productVersionSometimes the error is caused by incomplete system updates. Ensure your system software is fully up to date:
sudo softwareupdate -ia --verboseThis command:
- -i: Installs all available updates
- -a: Includes all available updates
- --verbose: Shows detailed progress
After updates complete, restart your Mac and try the xcode-select --install command again if the Command Line Tools still aren't working.
Note: On newer macOS versions, software updates may be found in System Settings > General > Software Update rather than through the command line.
If other methods don't work, you can completely remove and reinstall the Command Line Tools:
Step 1: Remove the existing installation
sudo rm -rf /Library/Developer/CommandLineToolsStep 2: Reinstall
xcode-select --installThis performs a clean installation and resolves issues caused by corrupted or partially installed tools.
Warning: This removes all Command Line Tools. Make sure you have an internet connection to download them again (approximately 130 MB).
After installation, verify everything is working:
git --version
xcode-select -pWhy this happens after every macOS update:
Apple's macOS upgrades often modify or remove system developer tools as part of the update process. This is by design - Apple wants to ensure compatibility between the system tools and the new macOS version. However, it means developers need to reinstall Command Line Tools after major updates. This has been a recurring pattern for many years and is unlikely to change.
What's in the Command Line Tools:
The Xcode Command Line Tools package includes:
- Git - version control
- clang/LLVM - C/C++/Objective-C compiler
- make - build automation
- ld - linker
- Headers - system headers for compilation
These tools are required by many development workflows, package managers (like Homebrew), and build systems.
Command Line Tools vs Full Xcode:
You do not need the full Xcode application (which is 12+ GB) just to use Git. The standalone Command Line Tools package (~130 MB) is sufficient for:
- Git version control
- Compiling most open-source software
- Using Homebrew
- Python/Ruby/Node.js development
You only need full Xcode if you're developing for iOS, macOS, watchOS, or tvOS.
Checking your current setup:
# Show current developer directory
xcode-select -p
# Check if Command Line Tools are installed
xcode-select --version
# List what's installed
ls /Library/Developer/CommandLineTools/
# Check Git specifically
which git
git --versionMultiple Xcode versions:
If you have multiple Xcode versions installed (e.g., from beta testing), you might need to specify which one to use:
# List available
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
# Or for beta
sudo xcode-select -s /Applications/Xcode-beta.app/Contents/DeveloperHomebrew-installed Git:
If you use Homebrew, you can install Git independently of the Command Line Tools:
brew install gitHowever, many Homebrew packages still require Command Line Tools for compilation, so you'll likely still need to install them eventually.
Corporate/Enterprise environments:
In managed environments where you can't install software directly:
1. Contact your IT department to install Command Line Tools
2. If using MDM (Mobile Device Management), the tools may need to be deployed through your organization's software distribution system
3. Some organizations pre-package Command Line Tools for easier deployment
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server
fatal: unable to access: Proxy auto-configuration failed
How to fix 'Proxy auto-configuration failed' in Git
fatal: unable to access: Authentication failed (proxy requires basic auth)
How to fix 'Authentication failed (proxy requires basic auth)' in Git
fatal: unable to access: no_proxy configuration not working
How to fix 'no_proxy configuration not working' in Git
fatal: unable to read tree object in treeless clone
How to fix 'unable to read tree object in treeless clone' in Git