To use Git properly, Xcode command line tools must be installed. Without it, you’ll get an error message when running Git commands. This guide explains what this error is and why you might see it. We’ll walk you through an example scenario so you can figure out how to fix this problem.
What is Git?
Git is the most popular version control system. Git keeps track of the changes you make to files, so you have a record of what has been done and can revert to specific versions if necessary. Git also facilitates collaboration by allowing multiple people’s changes to be merged into a single source.
So, whether you write code that only you will see or work in a team, Git is useful to you.
Git is a piece of software that runs on your computer. Your files, as well as their history, are saved on your computer. You can also store a copy of the files and their revision history on online hosts (such as GitHub or Bitbucket). Having a central location where you can upload your changes and download changes from others allows you to collaborate with other developers more easily. Git is able to automatically merge changes, allowing two people to work on different parts of the same file and then merge those changes without losing each other’s work!
Pro Tip: Scan your Mac for performance issues, junk files, harmful apps, and security threats
that can cause system issues or slow performance.
Special offer. About Outbyte, uninstall instructions, EULA, Privacy Policy.
Git is software that can be accessed via a command line (terminal) or a desktop app with a graphical user interface (GUI), such as Sourcetree.
What are XCode Tools?
Xcode is the Mac’s development and debugging environment, and it provides the necessary development files for Mac OS X and iOS applications.
Before they can develop software on a Mac, developers must first install the Xcode Command Line Tools.
Apple offers a full development environment for programmers called Xcode. You must install the full Xcode application if you are developing software for macOS, iOS, tvOS, or watchOS.
It isn’t pre-installed, but you can get it from the Apple developer website or the Mac App Store.
You won’t need the full Xcode application if you’re not developing software for an Apple device (it takes up over 40GB of disk space!).
Instead, you’ll download and install Xcode Command Line Tools. It’s a smaller package for software developers that includes command-line tools that run in the Terminal application.
These tools have been used by programmers on Unix operating systems since computing’s inception, and they are the foundation of almost all software development.
Fortunately, the Xcode Command Line Tools package only takes up 1.2GB of disk space.
To install Xcode Command Line Tools on a Mac, you have three options:
- install the entire Xcode package.
- install Xcode Command Line Tools via Terminal
- install Xcode Command Line Tools via Homebrew installation
Unless you’re developing software for an Apple device, we don’t recommend installing the full Xcode package. The download will take too long and will take up too much disk space. Instead, try one of two quicker methods.
Because the operating system is based on Unix, the long-standing standard for software development, macOS is the most popular platform for software development.
You’ll have a solid foundation for adding almost any open source development tool if you install Xcode Command Line Tools.
What Is the Git xcrun: error: invalid active developer path Error?
When running any git command — such as git pull, git push, git clone, git status, git branch, etc. —users were getting an error on various versions of macOS.
Some Mac Terminal users may discover that using pip, HomeBrew, and other command line tools fail or do not function properly, with an error message stating “xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)”. These command line tools may stop working after a macOS system software update if they previously worked.
The error message usually reads:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
What Causes Xcrun: error: invalid active developer path (/library/developer/commandlinetools)?
In most cases, the xcrun: error: invalid active developer path error appeared when trying to run the git command in the Terminal app after an update or upgrade. Most of the errors that popped up involved Macs that were recently updated to Big Sur.
The error notification above is self-explanatory. It says that the active developer path found at /Library/Developer/CommandLineTools is invalid. This means that the error is not related to git itself, but to the Command Line Tools instead.
This happens even when the Command Line Tools are installed on macOS and were working fine before. If the error appeared after upgrading your macOS, reinstalling the “Command Line Tools” on your Mac should resolve the problem with paths in the “Command Line Tools” installation.
How to Deal with Git Xcrun: Error: Invalid Active Developer Path
The first thing you need to do when you encounter this error is to close the Terminal window and relaunch it. After restarting the app, try running the command again to check if it works now. If the error was caused by a glitch, rebooting the app should fix it.
If you’re experiencing issues with the Terminal app, try running it with elevated permissions. For additional troubleshooting, you might consider using a system optimization tool like Outbyte macAries to remove junk files. Ensure the tool is right for you before using it.
If the error is so persistent that these troubleshooting steps don’t work, then follow the solutions below.
To fix this problem, install Xcode. If you are interested in iOS app development, you can install the full version and it will fix this problem too. Download the Xcode .dmg file from the Apple developer site.
If you are not using it a lot, you can find the command line tool package for Xcode and downloadand install the corresponding .dmg file. You can download it from Apple’s developer site.
Fix #1: Install or Reinstall the Command Line Tools.
If you don’t want to download anything and just want to run a few commands in Terminal to fix this problem, here is the solution for you:
- Start your Terminal application.You can also use any other terminal application. For macOS users: The Terminal app can be found in the Utilities folder of your Applications folder or use Spotlight to find it.
- In Terminal, type the following command and press Enter to install the command line tools: xcode-select –install
- This is the command that can be run in the terminal and will install the command line tools for Xcode. You should get the following output: xcode-select: note: install requested for command line developer tools
- Click the Install button.
- Accept the License Agreement by clicking the “Accept” button.
Let the installation do its job, don’t interrupt it. This may take a while, so be patient. Now restart the terminal application. I didn’t have to restart the terminal. But I know that in some cases it won’t work without rebooting.
Finally, you can retype the command that you used when you received the error message to ensure that it runs without errors. (in my case the command was git commit)
If you are told that the download requires more than 7GB of space, please note that you will beforced to download the Xcode application specifically from the Apple developer site.
The above command should fix the problem if you don’t also run the following command:
xcode-select –reset
Although this will fix your problem, the next step may be to set the path for the command line tools to run without Xcode: xcode-select –switch /Library/Developer/CommandLineTools
If you are working with Node.js and a module that requires the node type, you may find the following warning in your terminal:
xcode-select: error: tool ‘xcodebuild’ requires Xcode
but active developer directory ‘/Library/Developer/CommandLineTools’ is a command line tools instance
This error occurs when the developer directory xcodeselect points to / Library / Developer / CommandLineTools when full regular Xcode is required (occurs when CommandLineTools is installed after Xcode). You can quickly fix this problem by updating the developers directory to Xcode.app: sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Fix #2: Install From the Apple Developer Download Page
If you’ve installed or reinstalled Command Line Tools from Terminal, restarted your Mac, andthe error persists, you can also try installing Command Line Tools manually using a DMG file directly from Apple.
You need an Apple ID to access the download, then go to developer.apple.com and download Command Line Tools for Xcode (latest version) and install it manually.
If you are using Homebrew, you need to update it. You shouldn’t reinstall Homebrew or remove and then reinstall, a simple update should work.
Fix #3: Force Terminal to Use XCode
If you have Xcode installed on your Mac, you can skip the installation steps above and force the Terminal to use Xcode’s CommandLine tools. To do this, you need to use the following commands:
- sudo xcode-select –reset
- sudo xcodebuild -license
If you have multiple versions of Xcode, you can choose the version you want with this command: xcode-select –switch /Applications/Xcode.app
You can also choose to run the Command Line Tools without Xcode: xcode-select –switch /Library/Developer/CommandLineTools
Wrapping Up
This problem can occur after updating the operating system and rendering previously running services useless for a long time. However, the above solution should correct the xcrun: error: invalid active developer path (/library/developer/commandlinetools) issue you are facing. If none of these work for you, feel free to share your error message in the comment section below.