If you use macOS for development, you have almost certainly encountered the dreaded message: xcrun: error: invalid active developer path. It usually appears immediately after a major macOS upgrade, popping up in your terminal when you try to run git, make, python, or any command-line tool that relies on the Apple developer toolchain. The error effectively halts your workflow, stating that the system cannot find the necessary tools at the expected path, typically /Library/Developer/CommandLineTools.
This issue is not a bug in your code, nor is it a sign that your Mac is broken. It is a deliberate security and versioning mechanism employed by Apple. But every major macOS update (for example, moving from Ventura to Sonoma, or Sonoma to Sequoia) invalidates the existing command line tools installation because the new OS version ships with updated system libraries, SDKs, and compiler versions. The old tools are incompatible with the new system frameworks, so Apple disables the active developer path to prevent build errors or subtle runtime bugs caused by version mismatches Small thing, real impact..
You'll probably want to bookmark this section.
Understanding the Root Cause
To fix this efficiently, it helps to understand why it happens. Day to day, the xcrun utility is the gateway for locating and executing developer tools like clang, git, swift, and ld. When you type a command in the terminal, xcrun checks the active developer directory—configured via xcode-select—to find the correct binary Less friction, more output..
When you upgrade macOS, the operating system moves the old Command Line Tools package to a temporary location or marks it as invalid because the headers and libraries it points to (inside /Library/Developer/CommandLineTools/SDKs) no longer match the running kernel and user-space libraries. This means xcrun throws the "invalid active developer path" error to protect you from linking against outdated or missing SDKs Less friction, more output..
There are two primary scenarios where this occurs:
- Only Command Line Tools are installed: You installed the standalone package via
xcode-select --installpreviously, but never installed the full Xcode.Practically speaking, app. Also, 2. Full Xcode is installed: You have Xcode.app in/Applications, but the command line tools pointer (xcode-select -p) is still pointing to the standalone path, or the Xcode license hasn't been agreed to for the new version.
The Standard Fix: Reinstalling Command Line Tools
For the vast majority of users—especially those who do not need the full Xcode IDE (which consumes 15GB+ of disk space)—the fastest resolution is reinstalling the standalone Command Line Tools package. This downloads a fresh, compatible version signed for your current macOS build.
Open your Terminal and run the following command:
xcode-select --install
A software update popup window will appear. On the flip side, 5GB to 2GB of data, so ensure you have a stable internet connection. In practice, this process downloads roughly 1. Because of that, click Install, agree to the license agreement, and wait for the download to complete. Once the installer finishes, the active developer path is automatically reset to /Library/Developer/CommandLineTools, and the error should vanish immediately.
Verify the fix by running:
git --version
# or
xcrun --show-sdk-path
If these return version information and a valid SDK path (e.Which means g. , /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk), you are back in business No workaround needed..
Alternative Fix: Switching to Full Xcode
If you have the full Xcode.app installed from the Mac App Store (or manually via .xip), you might prefer to use its embedded toolchain instead of the standalone package. This is common for iOS/macOS app developers who need the simulators, Interface Builder, and device debugging capabilities.
First, ensure Xcode is actually in your Applications folder. Then, point the system to it using xcode-select with the --switch flag:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
You will be prompted for your administrator password. After running this, you must launch Xcode at least once to accept the updated license agreements for the new macOS version. If you skip this step, xcrun will continue to fail with a license acceptance error And that's really what it comes down to..
sudo xcodebuild -license accept
This approach ensures your terminal tools (compilers, linkers, git) match the exact version bundled with your Xcode IDE, eliminating "works in Xcode but fails in terminal" discrepancies Practical, not theoretical..
Troubleshooting Persistent Issues
Occasionally, the standard reinstall fails or the error persists. Here are the most common edge cases and how to resolve them.
1. Stuck or Corrupted Download
If the xcode-select --install popup spins indefinitely or fails with a network error, the temporary download files might be corrupted. You can manually trigger a cleanup and retry by removing the pending install receipt:
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
This forces a clean slate. In practice, if the GUI installer continues to fail, you can download the . Search for "Command Line Tools for Xcode [your macOS version]". dmg installer directly from the portal (requires Apple ID login). This is often more reliable on flaky networks But it adds up..
2. Permission Errors or "Operation Not Permitted"
On macOS versions with System Integrity Protection (SIP) and enhanced security (Ventura, Sonoma, Sequoia), the /Library/Developer folder is highly protected. If you manually deleted the folder via Finder or a third-party cleaner app, the system might struggle to recreate it with the correct permissions. Always use the terminal commands above (sudo rm -rf) rather than Finder to avoid ACL (Access Control List) issues Worth keeping that in mind..
3. Multiple Xcode Versions (Beta vs. Release)
Developers running Xcode Beta alongside the release version often face path confusion. If you switched to a Beta path (/Applications/Xcode-beta.app) and then deleted the Beta, the path becomes invalid. Run xcode-select -p to see where the system currently points. If it points to a non-existent app bundle, switch it back to the release version or the standalone tools using the --switch or --install commands detailed above.
4. Homebrew and Package Managers
If you use Homebrew, it relies heavily on the CLT headers for building bottles from source. After fixing the developer path, run brew doctor and brew update. Homebrew may complain about missing headers if the CLT reinstall didn't populate the SDK headers correctly (rare on newer macOS, but possible). A simple brew reinstall of failing packages usually resolves this.
Why xcode-select --reset Is Often Not Enough
You may see suggestions online to run sudo xcode-select --reset. According to the man page, this resets the path to the default (/Library/Developer/CommandLineTools if Xcode is not installed, or /Applications/Xcode.app/Contents/Developer if it is).
Still, this command does not download or install missing tools. It only changes the pointer. If the tools are missing at that default location (which is the case after an OS upgrade), --reset simply points xcrun at an empty directory. You will still get the "invalid active developer path" error. You must run the installer (--install) or point --switch at a valid, installed Xcode instance Easy to understand, harder to ignore. Still holds up..
Preventing Future Headaches
While you cannot stop macOS from invalidating the path during major upgrades, you can minimize friction:
- Automate the Check: Add a small function to your shell profile (
.zshrcor.bash_profile) to verify the path on shell startup.check_xcode_path() { if ! xcrun --show-sdk-path &>/