top of page

How to uninstall macOS Command Line Tools

Updated: Jul 3, 2022

This tutorial assumes you have the macOS command-line tools installed on your system. I tested the tutorial on a macOS Catalina installation.


Removing the Command Line Tools from your Mac is pretty simple. Just type the following command on the command line:

$ rm -fR /Library/Developer/CommandLineTools/

Warning: Be careful with this command. rm -fR is a forced and recursive removal of the path you enter. If you make a typo, you may regret removing something else. Because this is a forced removal, there is no way to get the removed files back.


How to verify the removal of the macOS XCode Command Line Tools from your system

If you are not sure this was successful, you can check this by opening your Terminal app and typing the following on your command line:

$ sudo xcode-select -p

Note: the sudo command means executing the xcode-select command as admin/root user. This command asks you for your system's admin/root password.


The following error message indicates you do not have the command-line tools installed:

xcode-select: error: unable to get active developer directory, use `sudo xcode-select --switch path/to/Xcode.app` to set one (or see `man xcode-select`)

Removing the command-line tools failed when you get the following response after confirming with the correct admin/root password.

/Library/Developer/CommandLineTools

Another way to check if the command line tools installation is by directly invoking one of the commands, like, e.g., git, in the following way:

$ /Library/Developer/CommandLineTools/usr/bin/git --version

This command directly invokes the git version packaged with the command-line tools by Apple. This command does not require finding git in the $PATH of your system. The command-line tools were successfully removed from your system when this command returns something like the following:

zsh: no such file or directory: /Library/Developer/CommandLineTools/usr/bin/git

When it returns something like the following, you did not successfully remove the command-line tools:

git version 2.24.3 (Apple Git-128)

How to reinstall the command-line tools

If you regret removing the command-line tools or if you need them again, you can reinstall them with the following commands:

$ xcode-select --install

You get the following pop-up. Click on install and confirm to accept the terms and conditions. The installation starts and completes in about a few minutes or so.



Next, type the following command to reset the default command-line tool path.

$ sudo xcode-select --reset

That should do the trick. You can use the above tests to check that you installed the command-line tools correctly again.








131 views0 comments

Comments


bottom of page