What the xcode-select Error Means
The xcode-select error occurs when the macOS system cannot find an active developer tools package (Xcode or Command Line Tools). The xcode-select utility manages the path to these tools. Typical error messages:
error: unable to get active developer directory
xcode-select: error: tool 'xcode-select' requires Xcode
These errors appear when attempting to use git, make, gcc, or other utilities from the terminal, as well as when working with Homebrew, CocoaPods, or building projects. The problem indicates that the system does not know where the developer tools are located.
Common Causes
- Command Line Tools are not installed — after a clean macOS installation or system update, the tools package may be missing.
- Xcode is installed, but the license agreement hasn't been accepted — without accepting the agreement, the tools are not activated.
- Incorrect path in
xcode-select— thexcode-selectcommand points to a non-existent or corrupted folder. DEVELOPER_DIRenvironment variable — if this variable is set and points to an incorrect path, the system ignoresxcode-selectsettings.- Corrupted installation — Command Line Tools or Xcode files may have been damaged during an update or software removal.
Solution 1: Install Command Line Tools
The most common scenario is missing Command Line Tools. Install them:
- Open Terminal (via Spotlight or
/Applications/Utilities/Terminal.app). - Run the command:
xcode-select --install - A dialog window will appear. Click Install and follow the instructions (administrator password required).
- After completion, restart the terminal.
💡 Tip: If the installation window doesn't appear, download the package manually from Apple's official website. Select Command Line Tools for Xcode for your macOS version.
Solution 2: Set the Path with xcode-select
If Command Line Tools or Xcode are already installed, but the path is not set:
- Check the current path:
xcode-select -p
If the output isxcode-select: error: unable to get active developer directory, the path is not set. - Set the path depending on your installed software:
- For Command Line Tools:
sudo xcode-select -s /Library/Developer/CommandLineTools - For full Xcode (if the app is in
/Applications):sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
⚠️ Important: Use
sudobecause changing the system path requires administrator privileges. Enter your password when prompted. - For Command Line Tools:
- Verify the path is set correctly:
xcode-select -p
It should output the selected path.
Solution 3: Accept the License Agreement
After installing Xcode or Command Line Tools, you may need to accept the license:
- In the terminal, run:
sudo xcodebuild -license - Scroll through the license text using the Spacebar.
- At the end, type
agreeand press Enter.
After this, the tools will become available. If the license was already accepted, the command will display a corresponding message.
Solution 4: Reinstall Command Line Tools
If the tools are corrupted, reinstall them:
- Remove the current version:
sudo rm -rf /Library/Developer/CommandLineTools - Reinstall as in Solution 1:
xcode-select --install - Set the path (if it wasn't set automatically):
sudo xcode-select -s /Library/Developer/CommandLineTools
Solution 5: Check the DEVELOPER_DIR Variable
The DEVELOPER_DIR environment variable can override the path set via xcode-select:
- Check if the variable is set:
echo $DEVELOPER_DIR
If the output is not empty, this could be the cause of the error. - Remove the variable for the current session:
unset DEVELOPER_DIR
Or edit the files~/.bash_profile,~/.zshrc, or~/.profile, removing the line withDEVELOPER_DIR. - Restart the terminal and check if the error is gone.
Prevention
- After a macOS update, always reinstall Command Line Tools, even if they were present before the update.
- Accept the Xcode license when first launching after installation.
- Do not change the
xcode-selectpath manually unless you are sure of the correct path. - Regularly update Command Line Tools via
softwareupdate --installor the App Store. - Check environment variables in scripts to avoid accidentally overriding
DEVELOPER_DIR.