The Problem
You're likely trying to run a standard dev tool like git, npm, or gcc when your terminal suddenly blocks you with this error message:
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
Most often, this happens after a macOS system update or when Xcode updates via the App Store. Apple requires a fresh acceptance of their Terms and Conditions before any developer binaries can run. Even if you never touch the Xcode IDE and only use the Command Line Tools (CLT), the system locks these tools until a license flag is updated in a protected directory.
Quick Fix: The One-Liner
Running this command is the fastest way to get back to work. It bypasses several minutes of manual scrolling and legal text:
sudo xcodebuild -license accept
Type your Mac password when prompted. Note that the terminal won't show any characters or asterisks as you type—this is normal security behavior. Just type it blindly and hit Enter. This immediately flags the license as accepted for every user on the system.
Why This Happens
Under the hood, macOS uses xcodebuild to manage shared developer components. Every time Apple bumps the version number (e.g., from Xcode 15.3 to 15.4), they reset the LicenseAccepted key. System permissions are the main hurdle here. Because the license status is stored in /Library/Preferences/, a standard user account can't write the update. That is why the error explicitly demands sudo.
Fix Approaches
Method 1: The Interactive Way
If the 'accept' flag fails or if you actually want to read what has changed in the agreement, use the interactive mode:
sudo xcodebuild -license
- Press Space to page through the document.
- At the very end, type
agreeand press Enter.
Method 2: Fixing Path Confusion
Sometimes your system loses track of where the developer tools are located. This often happens if you have both the 12GB+ Xcode app and the smaller standalone Command Line Tools installed. If the commands above return a "requires Xcode" error, reset your path:
sudo xcode-select --reset
Alternatively, if you want to point specifically to the full Xcode app in your Applications folder, use this:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Method 3: Fallback for Managed Macs
Managed work laptops with strict MDM profiles sometimes block sudo from writing to system files. If the terminal remains stubborn, try opening the Xcode app itself from your Applications folder. Usually, a GUI prompt will appear asking to "Install additional required components." Completing this visual prompt often clears the license block when CLI commands fail.
Verification: Confirming the Fix
Check if your tools are unblocked by running a simple version check without sudo:
git --version
xcode-select -p
If you see a valid version string (like git version 2.45.2) instead of the license error, you are ready to code again.
Further Reading
- Run
man xcodebuildto see all available build and license flags. - Review Apple's Technical Note TN2339 regarding Command Line Tools.
- If you use Homebrew, it is good practice to run
brew doctorafter a major license update to catch environment drift.

