Why is my xcode-select uninstall not working?

1.7k Views Asked by At

I am trying to uninstall xcode-select by removing its directory and all contents with;

sudo rm -rf /Library/Developer/CommandLineTools

However when after running the above command, I then run:

xcode-select -p

to verify that it's gone it reports back with the same original location;

/Library/Developer/CommandLineTools

I navigate via command line to the Developer folder and the CommandLineTools directory is no longer present. Also, when i run:

xcode-select --version

it still reports back with xcode-select version 2396.

Are these perhaps just variables that need resetting after I've already deleted xcode-select, and or what other steps ought I to take to fully delete xcode-select and it's settings/associations from my system?

3

There are 3 best solutions below

6
supsayan On

I am not really sure what you are trying to achieve, but the executable for the xcode-select is located in the /usr/bin.

If you are trying to remove the command line tools you need to delete /Library/Developer/CommandLineTools. If it is still there after you try to remove it you are doing something wrong.

If you installed the command line tools bundled with Xcode you need to completely remove Xcode first.

0
user20972863 On

You should use:

sudo xcode-select -r

You should read the help message.

xcode-select -h

You will find the option -r:

  -r, --reset                 reset to the default command line tools path

MacOS seems to remember the path even after you have uninstalled CLT. You need to reset it if you want.

0
Andreas Fischlin On

Yes, the system remembers the previous settings. This is necessary or you would have to redefine all the time after every restart, login, and new shell your development environment. xcode-select -p or xcode-select -print-path are the recommended techniques to learn about the current settings.

On newer macOS the needed information is stored at /var/db/xcode_select_link. The latter file is a symbolic link to the wanted development environment, e.g. /Library/Developer/CommandLineTools or /Applications/Xcode.app/Content/Developer. xcode-select -p does basically simply a readlink /var/db/xcode_select_link.

Note, this xcode_select_link influences your terminal commands in a convenient manner. Despite your $PATH may give /usr/bin a higher priority, a command line starting with gcc will not call /usr/bin/gcc but one preceded by a possibly very long path pointing deep into your Xcode.app package. Check it out, e.g. with which gcc while having an Xcode in use (e.g. after having executed sudo xcode-select -switch /Applications/Xcode.app and opened a new shell).