Git relies on various dependencies within Apple’s Xcode command line tools to function. If you do not have Xcode Tools installed on your system, you’ll encounter the xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)
when you try to run a Git command.
This guide discusses what this error means and why you may see it. We’ll walk you through an example scenario so you can learn how to solve this error.
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)
Many developer tools, like the Git version control system, rely on Xcode Tools. Xcode Tools is a command line package that provides a suite of software development tools built by Apple.
For Git to work, you must have a Xcode Tools installed. The Xcode Tools suite does not come built-in with a Mac because it is primarily for developer use. Most non-technical computer users will never need to have Xcode Tools on their system.
You may not already have Xcode Tools on your system if you have just moved to a new computer. You need to reinstall Xcode Tools before you can use Git. If you have reinstalled your system, or uninstalled Xcode Tools, you will need to initiate a new install to fix this error.
An Example Scenario
We’ve just moved to a new Mac development environment. Our new computer has not yet been configured with Git. We are going to start to configure our environment.
To start, we use the git config command to save our name onto our Git installation:
git config --global user.name "Career Karma"
This command returns an error:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
The git command cannot execute because we do not have Xcode Tools installed.
The Solution
The easiest way to install Xcode Tools is to do so from the command line. You can also install Xcode Tools from the Apple Developer website. We’ll walk about this solution later in the article.
You do not need to install Xcode to install Xcode Tools. Xcode itself can be over 10GB in size. You should only install Xcode if you have a need to do so, such as if you are working on an iOS development project that depends on Xcode.
Macs come with a built-in command that lets you install Xcode Tools called xcode-select. Let’s install Xcode Tools on our system using this Linux command:
xcode-select --install
The –install flag denotes that we want to install Xcode Tools. After running this command, you’ll receive a message that informs you the installation process is about to begin:
xcode-select: note: install requested for command line developer tools
A new window will open up in which you will be asked to install Xcode Tools. The installation window works like any other window that you would see when you install a piece of software.
Xcode Tools can take a while to install as it is a large suite of tools. You can still work in the background while the installation is running but you can’t run Git until the installation process has completed.
Once you have installed Xcode Tools, restart your terminal. This is important because your old shell environment may not have been updated to include your installation of Xcode Tools. If you still receive the xcrun error, restart your computer.
Let’s try to configure our Git username:
git config --global user.name "Career Karma"
No errors have been raised. This means our user name has been successfully changed. Our installation of developer tools has worked.
If this solution does not work, you may need to reset your xcode-select instance. You can do this using the –reset flag:
xcode-select --reset
You will be prompted to install Xcode Tools after you have run this command. You should only use the –reset flag if you have been unable to install Xcode Tools using the –install flag.
Conclusion
The xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)
error is raised when you try to run a git command without having Xcode Tools installed.
To fix this error, run xcode-select –install and install Xcode Tools. If this does not work, try to run the xcode-select command with the –reset flag.
About us: Career Karma is a platform designed to help job seekers find, research, and connect with job training programs to advance their careers. Learn about the CK publication.