Git xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)

Fix “xcrun: error: invalid active developer path” Error in Terminal on MacOS

 

The error message "xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)" occurs when Git is trying to run a command that relies on the Xcode command line tools, but the tools are not installed or are not configured correctly.

This error usually appears on macOS when trying to use Git on a system that doesn't have the Xcode command line tools installed or when the command line tools are not properly configured.

 

To resolve this issue, you need to install the Xcode command line tools. You can do this by running the following command in the terminal:

xcode-select --install

 

This will prompt you to install the command line tools.

If you already have Xcode command line tools installed, but still getting the error, you can try to reset the command line tools path by running this command in the terminal:

 

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

 

This command set the developer path to the Xcode app which will resolve the issue.

If you still have the issue, it's best to check the version of Xcode you have installed, and make sure it's the latest version. If you don't need xcode you can also install Command Line Tools for Xcode by downloading the package from the apple developer website.

 

Alternatively, you can use another package manager like Homebrew to install Git, which will not require the Xcode command line tools to be installed.

brew install git

 

This command installs the latest version of git via Homebrew package manager.

Please note that, by installing git via Homebrew, you will have to use the brew-installed version of git, which may be located in a different directory than the version that comes with Xcode.

 

Still seeing xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)?

 

If you are still seeing the error message "xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)" even after installing the Xcode command line tools or resetting the developer path, there may be an issue with the configuration of the command line tools on your system.

 

Here are some additional steps you can try to resolve the issue:

 

1. Check the current developer path: You can use the following command to check the current developer path:

xcode-select -p

This command should print the path to the active developer directory. If the path is not set or is set to an invalid directory, you will need to set it to the correct path.

 

2.  Check the version of xcode-select: You can check the version of xcode-select installed on your system by using the following command:

xcode-select -v

This command should print the version of xcode-select installed on your system. If you have multiple version of xcode-select installed on your system, you may need to uninstall the old version.

 

3. Reinstall the Command Line Tools You can also try to reinstall the Command Line Tools by running the command

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

This command removes the current command line tools and installs the latest version of command line tools available.

 

4. Check the environment variables You may also check if the environment variables are set correctly, which could be causing the issue, by running the command

echo $DEVELOPER_DIR

If the output is empty, you may need to set the DEVELOPER_DIR environment variable by running the command

export DEVELOPER_DIR='/Library/Developer/CommandLineTools'

 

5. Check if you have multiple version of Xcode installed You may also have multiple versions of Xcode installed on your system, which can cause the issue. You can check the version of Xcode installed by running the command

xcode-select --print-path

This command will show the path to the version of Xcode that is currently selected.

 

If you have multiple version of Xcode installed, you can select the version you want to use by running

sudo xcode-select -s /path/to/Xcode.app

 

Please note that you may need to try different combinations of the above steps to resolve the issue. If none of these steps work, you may need to reinstall Xcode or seek additional help from Apple or other resources.


Tags:

git

Share:

Related posts