How to Fix macOS xcrun: error: invalid active developer path
In this tutorial, you'll learn about How to Fix macOS xcrun: error: invalid active developer path. We cover key concepts, practical examples, and best practices.
The Problem
You run a command like git, make, or xcrun and get:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools),
missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Xcode Command Line Tools are missing, corrupted, or the path is misconfigured.
Quick Fix
Step 1: Reinstall Xcode Command Line Tools
xcode-select --install
A dialog appears asking you to install the tools. Click Install.
Step 2: If the dialog says "already installed," force a reinstall
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
Step 3: Reset the active developer directory
sudo xcode-select --reset
This resets the path to the default active developer directory.
Step 4: Point xcode-select to Xcode app (if installed)
If you have Xcode installed from the Mac App Store:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
Step 5: Accept the Xcode license
sudo xcodebuild -license accept
If the license has not been accepted, many developer tools fail.
Step 6: Verify the installation
xcrun --show-sdk-path
Expected:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
Or:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
Step 7: Install only the Command Line Tools (without full Xcode)
xcode-select --install
For macOS Ventura and later, the command line tools can be installed independently of Xcode.
Step 8: Check for macOS SDK compatibility
ls /Library/Developer/CommandLineTools/SDKs/
After a major macOS upgrade, the existing SDK may be incompatible. Reinstall the command line tools.
Prevention
- Reinstall Xcode Command Line Tools after every major macOS upgrade.
- Keep Xcode updated through the Mac App Store.
- Run
xcode-select --installproactively before using developer tools.
Common Mistakes with xcrun error
- Misunderstanding that
Stringis[Char]with poor performance for large text operations - Using
foldlinstead offoldl'causing stack overflow on large lists - Forgetting
deriving (Show, Eq)on custom data types needed for debugging
These mistakes appear frequently in real-world MACOS code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
DodaTech Tool Reference
Doda Browser's Developer Environment Checker validates the Xcode Command Line Tools installation and alerts when tools are missing or outdated.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro