1

I'm extremely surprised this question wasn't asked, or at least I wasn't able to find it.

Is there a way to install command line tools for MacOS without installing the full XCode suite? I'm low on storage and I find it hard to swallow that I have to free up 20+ GB just to be able to do:

$ python -m http.server

Especially since python is already installed...

EDIT #2: This was just an example, my question is about xcode cli tools.

I want to be able to use make, gcc, install brew packages etc...

EDIT: Replying to the comment and why I think "python is installed"

Simple: Everything was working, until I uninstalled XCode to free up 11GB that I needed (and I don't use XCode at all). Also:

$ which python3
/usr/bin/python3
$ ls -lh /usr/bin/python3
-rwxr-xr-x  76 root  wheel   163K May  9  2022 /usr/bin/python3
$ file /usr/bin/python3
/usr/bin/python3: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64
- Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e
- Mach-O 64-bit executable arm64e]
/usr/bin/python3 (for architecture x86_64):     Mach-O 64-bit executable x86_64
/usr/bin/python3 (for architecture arm64e):     Mach-O 64-bit executable arm64e
$ hexdump -C /usr/bin/python3 | head
00000000  ca fe ba be 00 00 00 02  01 00 00 07 00 00 00 03  |............|
00000010  00 00 40 00 00 01 0c f0  00 00 00 0e 01 00 00 0c  |..@............|
00000020  80 00 00 02 00 01 80 00  00 01 0c d0 00 00 00 0e  |...............|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00004000  cf fa ed fe 07 00 00 01  03 00 00 00 02 00 00 00  |............|
00004010  12 00 00 00 40 06 00 00  85 00 20 00 00 00 00 00  |....@..... .....|
00004020  19 00 00 00 48 00 00 00  5f 5f 50 41 47 45 5a 45  |....H...__PAGEZE|
00004030  52 4f 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |RO..............|
00004040  00 00 00 00 01 00 00 00  00 00 00 00 00 00 00 00  |................|
$ md5sum /usr/bin/python3
fac4668657765c8dfe89d8995acfb5a2  /usr/bin/python3
$ python3 -m http.server
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

PS: I know this answer exists but it assumes I get to choose anything after running xcode-select --install which hasn't been the case since Big Sur as far as I know

5
  • If you truly have python installed already, no, you don't have to install anything else to use http.server. Re the answer you link, it certainly doesn't say what you seem to think it says, even ignoring the Homebrew bias. If you want the CLT, install the CLT, with xcode-select --install. Commented Nov 22, 2022 at 15:47
  • I've updated my question to explain why I think I have python installed. About the the link: "For my machine, running xcode-select --install and choosing to install the tools from the window that popped up helped fix the problem". Maybe I over-interpreted the word choosing. For me xcode-select --install tried to install 20GB worth of data and I don't have the required disk space
    – Mouradif
    Commented Nov 22, 2022 at 15:59
  • 2
    That's the stub, not an actual python install. It looks like you had a CLT install (which installs python 3.9) and deleted it. Commented Nov 22, 2022 at 16:03
  • So you're saying when I uninstalled XCode, it also uninstalled python? Also, I just mentioned python3 -m http.server as an example. Before coming to ask this rather straightforward question I was actually trying to brew install redis. The question was: "s there a way to install command line tools for MacOS without installing the full XCode suite?" (and the title hints: "for Monterey").
    – Mouradif
    Commented Nov 22, 2022 at 16:11
  • If you just want python, install it from python.org.
    – benwiggy
    Commented Nov 22, 2022 at 16:12

2 Answers 2

3

I found the solution:

Downloading CLT directly from : https://developer.apple.com/download/all/

At the moment of posting, it's version 14.1: a 704MB download for a 3.4GB installation. Still makes me wonder why but I'll take it.

Just a bit of extra context for the people who commented and replied. The question was:

Is there a way to install command line tools for MacOS without installing the full XCode suite?

(I added boldness here for clarity)

the Python bit was an explanation of why I need CLT, and the

I have to free up 20+ GB just to be able to do...

was the explanation of why I don't want to install CLT with xcode-select --install (which just opened a window asking me to agree to the installation then failed because I needed to free up 21GB).

1
  • Why is because the SDK's are in it. Commented Nov 22, 2022 at 20:50
2

The xcrun: error: invalid active developer path implies that you don't have the CLT installed. As others already said, run xcode-select --install to fix this. Homebrew relies on CTL being present, so if you want to run brew you must install it.

If all you need is a pre-compiled python, download it from https://www.python.org/downloads/macos/.

6
  • My question is: Is there an alternative way that doesn't take 20+GB ?
    – Mouradif
    Commented Nov 22, 2022 at 17:32
  • 1
    My CLT install is ~3gb, and I installed it with xcode-select --install. This laptop has never had Xcode on it. Commented Nov 22, 2022 at 20:49
  • @MarcWilson on Monterey ? When I run that command, it doesn't give me any option and immediately tries to download XCode (and fails because I don't have the free space)
    – Mouradif
    Commented Nov 25, 2022 at 16:00
  • Yes, witht that command. Commented Nov 25, 2022 at 21:58
  • 1
    There are no options to that command, and no, it doesn't download Xcode. Yes,. on Monterey. Commented Aug 12, 2023 at 14:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .