[Solved] XCRUN: error: invalid active developer path

As a software developer, you might have encountered the error message xcrun: error: invalid active developer path while trying to run certain commands in the terminal. This error can be frustrating and confusing, but don’t worry – we’ll walk you through the process of fixing it.

What causes the XCRUN: error: invalid active developer path error?

This error occurs when the command line tools for Xcode are missing or not properly configured on your system. The command line tools are a set of utilities that allow developers to perform various tasks in the terminal, such as compiling code, running tests, and more Source.

How to fix the error

There are a few methods to fix this error. We’ll cover two popular solutions below.

Method 1: Installing or reinstalling Command Line Tools

  1. Open the terminal app on your Mac. You can find it in the Utilities folder of your Applications folder, or use Spotlight to search for it.
  2. In the terminal, type the following command and press Enter: xcode-select --install Source.
  3. Agree to the “License Agreement” by clicking the Agree button.
  4. Let the installation process run without interruption. This may take a few minutes, so be patient.
  5. Restart the terminal app. You might not need to do this, but some users have reported issues without restarting.
  6. Retype the command that caused the error to verify that it now runs without issues.

This method should resolve the error for most users. However, if you’re still experiencing issues, you can try the second method below.

Method 2: Resetting the active developer path

If you’ve already installed Command Line Tools but are still experiencing the error, you may need to reset the active developer path. To do this:

  1. Open the terminal app on your Mac.
  2. Type the following command and press Enter: sudo xcode-select --reset Source.

This command resets the active developer path, which should resolve the error.

Alternative solution

If neither of the above methods work for you, you can try updating the Command Line Tools through Xcode preferences:

  1. Open Xcode.
  2. Go to Preferences (press ⌘,).
  3. Navigate to the Locations tab.
  4. For the “Command Line Tools” option, select the current version. Even if the current version is already set, reselect it.

Wrapping up

By following the steps outlined above, you should be able to resolve the xcrun: error: invalid active developer path error on your Mac. Remember that it’s essential to keep your development tools up-to-date and properly configured to avoid such issues in the future. Happy coding!