How to fix Git after macOS update with ‘xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)’ error?
After updating macOS or restarting my computer, I’m encountering the following error when trying to use Git commands like ‘git status’:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
This issue occurs after major macOS updates and prevents Git from working properly. How can I fix Git and restore the command-line tools functionality?
The “xcrun: error: invalid active developer path” error occurs after macOS updates because the Command Line Tools installation becomes corrupted or its path reference is invalidated. The most effective fix is to reinstall the Command Line Tools using xcode-select --install in Terminal, which typically resolves the issue within a few minutes. You can also try removing corrupted tools first with sudo rm -rf /Library/Developer/CommandLineTools before reinstalling, or reset the path configuration with xcode-select --reset to restore proper developer tool functionality.
Contents
- Understanding the Error
- Quick Fix Methods
- Step-by-Step Solutions
- Alternative Approaches
- Prevention and Maintenance
- Troubleshooting
Understanding the Error
The “xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)” error message indicates that your macOS system cannot locate the required developer tools, specifically the xcrun utility that Git depends on. This typically happens after major macOS updates because:
- The Command Line Tools installation becomes corrupted during the update process
- The path reference to the developer tools is invalidated
- System components are moved or reorganized during the update
- Security permissions are reset
As Apple Stack Exchange explains, this error specifically affects Git because it relies on xcrun to access various developer utilities and compilers that are part of the Xcode Command Line Tools package.
The error message is quite specific: xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun - this tells you exactly what’s missing and where it should be located.
Quick Fix Methods
Method 1: Install Command Line Tools (Most Common Solution)
The simplest and most reliable fix is to reinstall the Command Line Tools:
xcode-select --install
This command will:
- Open a system dialog asking for permission to install
- Download and install the latest Command Line Tools
- Update the necessary path references automatically
According to Built In, this single command solves the issue for most users. The process typically takes 5-10 minutes and requires an internet connection.
Method 2: Use System Preferences Update
Some users report success using the built-in Software Update tool:
- Go to → System Preferences → Software Update
- Look for “Xcode utilities update” or similar
- Install the update
- Restart your Mac if prompted
As mentioned in the Stack Overflow discussion, this approach worked for users upgrading to macOS Catalina.
Method 3: Reset Developer Tools Path
If the installation appears complete but still doesn’t work, try resetting the path:
xcode-select --reset
This command resets the developer directory path to the default location without reinstalling anything, which can resolve path reference issues that occurred during the macOS update.
Step-by-Step Solutions
Comprehensive Fix Script
For a thorough solution, you can use this comprehensive script that combines multiple approaches:
#!/bin/bash
echo "Removing old CommandLineTools..."
sudo rm -rf /Library/Developer/CommandLineTools
echo "Installing CommandLineTools..."
sudo xcode-select --install
echo "Resetting xcode-select..."
xcode-select --reset
sudo xcode-select --switch /Library/Developer/CommandLineTools
echo "Verifying Git installation..."
git --version
echo "Fix complete!"
This script, as shared on Medium, performs a complete reset of the developer tools environment by:
- Removing any corrupted installation
- Installing fresh tools
- Resetting the path configuration
- Verifying the fix worked
Detailed Manual Steps
If you prefer to do this manually step by step:
-
Check current status:
bashxcode-select --print-path
-
Remove corrupted tools (if any):
bashsudo rm -rf /Library/Developer/CommandLineTools -
Install fresh tools:
bashxcode-select --install
- Click “Install” when prompted
- Agree to the terms and conditions
- Wait for installation to complete
-
Reset path configuration:
bashxcode-select --reset
-
Switch to correct path (if needed):
bashsudo xcode-select --switch /Library/Developer/CommandLineTools -
Verify the fix:
bashgit --version xcodebuild -version
Alternative Approaches
Method 4: Use Xcode.app Path
If you have Xcode installed, you can switch to its developer path:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
This method is useful if you have Xcode installed and want to use its developer tools instead of the standalone Command Line Tools package. According to SetApp, this approach can be more reliable in some cases.
Method 5: Manual Xcode Update
For persistent issues, consider updating Xcode itself:
- Open the App Store
- Search for “Xcode”
- Update to the latest version
- Run Xcode at least once to complete the setup
- Try Git commands again
This ensures you have the most compatible version of developer tools for your current macOS version.
Method 6: Homebrew Alternative
If you use Homebrew, you can reinstall Git through it:
brew uninstall git brew install git
This method is particularly useful if the issue is specifically with the Git installation rather than the broader developer tools ecosystem.
Prevention and Maintenance
Regular Maintenance Tips
To prevent this issue from recurring:
- Keep macOS updated: Regular updates maintain compatibility between system components
- Update Xcode/Command Line Tools: Check for updates periodically
- Backup your system: Before major updates, create a Time Machine backup
- Use version control: Keep your projects in Git to easily recover from system issues
System Health Checks
Regularly check your developer tools health:
xcode-select --version git --version xcodebuild -version
If any of these commands fail, address the issue immediately before it affects your workflow.
Automated Monitoring
Consider adding these checks to your shell profile or periodic scripts:
# Add to ~/.bashrc or ~/.zshrc
check_dev_tools() {
if ! command -v git >/dev/null 2>&1; then
echo "Warning: Git not found - checking developer tools..."
if ! xcode-select --print-path &>/dev/null; then
echo "Developer tools path invalid - running fix..."
xcode-select --install
fi
fi
}
# Schedule with cron for automatic monitoring
# 0 9 * * * /path/to/check_dev_tools.sh
Troubleshooting
Common Issues and Solutions
Problem: xcode-select --install fails or hangs
- Solution: Try the manual removal method first, then reinstall
- Alternative: Use System Preferences Software Update instead
Problem: Installation completes but Git still doesn’t work
- Solution: Try
xcode-select --switch /Library/Developer/CommandLineTools - Alternative: Restart your Mac and try again
Problem: Permission denied errors
- Solution: Ensure you’re using
sudofor system-level commands - Alternative: Check disk permissions in System Preferences
Problem: Download fails or is slow
- Solution: Use a stable internet connection
- Alternative: Try updating Xcode through App Store instead
When to Contact Support
If none of the above solutions work, consider:
- Apple Developer Forums: Apple Developer Forums have community discussions about this issue
- Genius Bar: Visit an Apple Store for hardware/software diagnostics
- Apple Support: Contact Apple Support for official assistance
Log Analysis
For advanced troubleshooting, check these logs:
# Check system logs for developer tools issues
log show --predicate 'senderImagePath contains "xcode"' --last 1h
# Check Console.app for related errors
# Look for "xcrun" or "CommandLineTools" entries
Sources
- Stack Overflow - Git not working after macOS update
- Apple Stack Exchange - Invalid active developer path
- OS X Daily - Fix xcrun error
- Built In - How to Fix “Invalid Active Developer Path” in Git
- SetApp - How to fix xcrun error
- Apple Developer Forums - xcrun error discussion
- Mkyong - Git on macOS xcrun error
- Medium - Resolving git problems after macOS update
Conclusion
The “xcrun: error: invalid active developer path” error is a common issue after macOS updates that can be resolved quickly using the right approach. The most effective solution is running xcode-select --install in Terminal, which reinstall the necessary Command Line Tools. For persistent issues, use the comprehensive removal and reinstallation script provided, or try alternative methods like updating Xcode through System Preferences.
To prevent future occurrences, maintain regular updates for both macOS and your developer tools, and consider creating automated monitoring scripts. If standard fixes don’t work, check for permission issues, try alternative installation methods, or seek assistance from Apple support or developer communities with experience in this specific macOS update-related problem.