ClearDisk
Buy for $10Download ClearDiskDownload
A LITTLE MORE CLARITY

How to reinstall Command Line Tools on Mac

Check your active developer path with xcode-select -p and your receipt with pkgutil --pkg-info=com.apple.pkg.CLTools_Executables before removing anything, because a stale path or pending Software Update often causes the error. If the standalone tools in /Library/Developer/CommandLineTools are genuinely broken, remove that folder and run xcode-select --install.

1. Check the active path and package receipt

Run these checks in the same Terminal session where the problem occurs. They inspect configuration; they do not install or remove tools. If you run them on a different Mac, in a remote shell or from an IDE, the result may differ.

xcode-select -p prints the selected developer directory. /Library/Developer/CommandLineTools is the standalone package; a path inside Xcode.app uses the full app. pkgutil reports the standalone package receipt and version. A receipt does not verify every installed file, and no receipt does not prove that Xcode or usable developer tools are absent.

printenv DEVELOPER_DIR shows a shell override when one is set. No output with exit status 1 means that variable is unset. A stale override can direct tools to a missing location even when another installation is available.

xcode-select -p
pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
printenv DEVELOPER_DIR

Fix “Command Line Tools are already installed” and path errors

Keep the complete error message, including the path it names. A successful package installation can still leave a command pointing at another developer directory.

  • Invalid active developer path or missing xcrun: inspect the named path and any DEVELOPER_DIR override. A moved Xcode app or missing standalone directory needs a different response from an incompatible installed package.
  • Command line tools are already installed: this message alone does not show that the installation is broken. Check Software Update and the selected path before deciding to remove anything.
  • Tool xcodebuild requires Xcode: install or select the full Xcode app. Reinstalling the standalone package will not add tools that Apple ships only with Xcode.
  • License or first-launch setup error: open the selected Xcode app and complete its requested setup. Replacing the standalone package does not address an unfinished Xcode setup.

2. Correct a stale selection if the tools already exist

If the error names an old or moved Xcode copy, check the app’s actual location first. To test an installed Xcode at the standard path for one command, use the example below. It does not change the system-wide selection. If your app has another name or location, use that exact path.

A successful result is the path to clang inside that Xcode installation. If you need to make it the default, sudo xcode-select --switch /Applications/Xcode.app changes the selection for all users. For an existing standalone package, the corresponding destination is /Library/Developer/CommandLineTools. Choose the installation you intend to use; do not run both switches as a sequence.

xcode-select --reset clears a custom system-wide selection. It does not repair missing files or remove a DEVELOPER_DIR override in your shell. Check the override’s source before changing shell or IDE configuration.

env DEVELOPER_DIR="/Applications/Xcode.app" xcrun --find clang

3. Install or update a compatible package

For a missing standalone package, xcode-select --install requests Apple’s installer. Finish the dialog before checking again. If macOS reports that tools are already installed, open System Settings → General → Software Update and look for a compatible update.

If the installer cannot find a package, check Apple’s system-requirements table and the Command Line Tools download details for your macOS version. Apple’s developer downloads require an Apple Account, but no paid membership. Choose the compatible package rather than assuming the highest version number will run on your Mac.

If the downloaded installer reports an unsupported macOS version or fails, keep its error and resolve that mismatch before deleting a working installation. Xcode already includes developer tools; you may only need to select it.

xcode-select --install

4. Remove the standalone package only if a reinstall is still needed

Use this step after checking the selection and compatible updates, when you have decided to replace the standalone installation. Save work and stop builds that depend on it. Have a compatible installer available first; removal does not guarantee that the replacement download will succeed.

Apple documents the exact command below to uninstall the standalone package. It permanently removes that directory without moving it to Trash or asking for a second confirmation. Do not shorten the path or substitute another folder. Tools and builds that rely on this installation may stop working until it is restored.

After removal, install the compatible package and repeat the verification checks below. Do not forget package receipts as a routine repair step: Apple describes receipt removal separately as an opt-out from package updates.

sudo rm -rf /Library/Developer/CommandLineTools

Installing over SSH or on a managed Mac

The graphical installer needs someone to complete its dialog. For an unattended installation, an administrator can use a compatible package downloaded from Apple and the macOS installer tool. Confirm the package path and deployment requirements before running an administrator installation.

On a managed Mac, follow the organization’s software-deployment process. Avoid relying on undocumented placeholder files to force a package into Software Update. A package that cannot be found or is not offered for this Mac needs investigation, not repeated deletion.

5. Verify the compiler and SDK, then retry the failed command

xcrun --find clang should return a compiler path under the intended developer installation. xcrun --show-sdk-path should return the selected SDK path. Errors here are useful: keep their full text instead of hiding stderr. A path lookup alone does not prove that your project will build; retry the original command after these checks.

In our read-only check on macOS 27.0.1 on October 26, 2026, the standalone package had a receipt while xcode-select and xcrun selected /Applications/Xcode.app/Contents/Developer. Setting DEVELOPER_DIR to a nonexistent disposable path for one command produced a missing-path error and exit status 1. No installed tools were removed, switched or reinstalled for this check.

ClearDisk can help inspect developer storage, but it does not repair the selected toolchain or validate a Command Line Tools installation. Keep cleanup separate from diagnosing a failed build.

xcrun --find clang
xcrun --show-sdk-path

Common questions

How do I check if the Xcode Command Line Tools are installed on my Mac?

Check the standalone package receipt with pkgutil --pkg-info=com.apple.pkg.CLTools_Executables, then inspect xcode-select -p and xcrun --find clang. A receipt describes installation records; it does not prove that every file is present or that the standalone package is selected. Full Xcode can provide the tools separately.

Why does Terminal say the active developer path is invalid after a macOS upgrade?

Inspect the exact path in the error and any DEVELOPER_DIR override. The selected folder may be missing or moved. Also check for a Command Line Tools update compatible with the new macOS version. The error alone does not establish that reinstalling is the correct fix.

Do I need to remove the old Command Line Tools before reinstalling them?

Try a compatible update and check the selected path first. Apple documents how to uninstall the standalone package, but removal is permanent and can interrupt dependent tools. Have the compatible replacement available before choosing that route.

Can Xcode and the standalone Command Line Tools both be installed at the same time?

Yes. The active developer directory and any DEVELOPER_DIR override determine which installation Apple’s tool shims use. Xcode includes its own tools, so a separate standalone package is not always necessary.

References & further reading

These guides combine the linked official guidance with ClearDisk’s documented behavior. Your files and app settings determine the right next step.

Main guide: developer storage on Mac · Related pillar: clear Xcode Derived Data on Mac · Browse all Developer storage guides →

FROM A NUMBER TO AN ANSWER

See what’s using
your space.

Explore your Mac with ClearDisk’s free local scanner.
Review the files. Keep the control.

Download free scannermacOS 15+ · version 2.2.1Cleanup license: $10 once