NeuroAgent

Fix Git xcrun Error After macOS Update

Fix Git's 'xcrun: error: invalid active developer path' issue after macOS updates. Complete guide with step-by-step solutions to restore Git functionality and command-line tools.

Question

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?

NeuroAgent

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

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:

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

  1. Go to  → System Preferences → Software Update
  2. Look for “Xcode utilities update” or similar
  3. Install the update
  4. 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:

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

bash
#!/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:

  1. Removing any corrupted installation
  2. Installing fresh tools
  3. Resetting the path configuration
  4. Verifying the fix worked

Detailed Manual Steps

If you prefer to do this manually step by step:

  1. Check current status:

    bash
    xcode-select --print-path
    
  2. Remove corrupted tools (if any):

    bash
    sudo rm -rf /Library/Developer/CommandLineTools
    
  3. Install fresh tools:

    bash
    xcode-select --install
    
    • Click “Install” when prompted
    • Agree to the terms and conditions
    • Wait for installation to complete
  4. Reset path configuration:

    bash
    xcode-select --reset
    
  5. Switch to correct path (if needed):

    bash
    sudo xcode-select --switch /Library/Developer/CommandLineTools
    
  6. Verify the fix:

    bash
    git --version
    xcodebuild -version
    

Alternative Approaches

Method 4: Use Xcode.app Path

If you have Xcode installed, you can switch to its developer path:

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

  1. Open the App Store
  2. Search for “Xcode”
  3. Update to the latest version
  4. Run Xcode at least once to complete the setup
  5. 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:

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

  1. Keep macOS updated: Regular updates maintain compatibility between system components
  2. Update Xcode/Command Line Tools: Check for updates periodically
  3. Backup your system: Before major updates, create a Time Machine backup
  4. Use version control: Keep your projects in Git to easily recover from system issues

System Health Checks

Regularly check your developer tools health:

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

bash
# 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 sudo for 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:

  1. Apple Developer Forums: Apple Developer Forums have community discussions about this issue
  2. Genius Bar: Visit an Apple Store for hardware/software diagnostics
  3. Apple Support: Contact Apple Support for official assistance

Log Analysis

For advanced troubleshooting, check these logs:

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

  1. Stack Overflow - Git not working after macOS update
  2. Apple Stack Exchange - Invalid active developer path
  3. OS X Daily - Fix xcrun error
  4. Built In - How to Fix “Invalid Active Developer Path” in Git
  5. SetApp - How to fix xcrun error
  6. Apple Developer Forums - xcrun error discussion
  7. Mkyong - Git on macOS xcrun error
  8. 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.