0

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?

jbk
  • 1,911
  • 19
  • 36

3 Answers3

0

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.

supsayan
  • 21
  • 3
  • I only have the xcode-select command line tools installed, which I am trying to fully remove in order to install an earlier version because my current version conflicts with some other software that I am trying to install (an early version of Ruby). So i guess the answer to my question is; 'delete the executable in `/user/bin`?' – jbk Nov 11 '22 at 09:37
  • Not really, it is an executable of the installer, not the packages and tools themselves - that would not help. You need to figure out what is happening - why the CommandLineTools folder is still there after rm -rf (if I understood you correctly) – supsayan Nov 11 '22 at 09:49
  • No the CommandLineTools folder is no longer there; 'I navigate via command line to the Developer folder and the CommandLineTools directory is no longer present.', but the -p and --version commands still return the values reported even after the folder is no longer there. – jbk Nov 11 '22 at 10:02
  • Did you close the terminal after? Just to double check, reboot the system after removing the folder and then check -p and --version. – supsayan Nov 11 '22 at 10:11
  • Yes terminal shut down and restarted (but not the entire machine) and still outputs those same readings (will restart entire machine when I've finished doing some heavy downloads I'm in the middle of in case that makes a difference). – jbk Nov 11 '22 at 10:45
  • Ended up reinstalling entire new version of xcode, which prompted me to `sudo xcode-select --switch /Applications/Xcode.app`, therefore this is no longer an issue for me. Not quite sure whether a machine reboot would have solved the original issue question that I was trying to answer, but I suspect so. Post your reboot suggestion as an answer and I'll accept it. Thanks for guidance. – jbk Nov 11 '22 at 11:38
0

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.

Adriaan
  • 17,741
  • 7
  • 42
  • 75
0

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).