5

I already have Xcode installed and want to install Homebrew. It wants to install Xcode Command Line Tools and I don't have space. Is there a way to install Homebrew without it trying to install the Command Line Tools?

2
  • 4
    If there is insufficient space for the one, there may not be room for the other. Time to do some cleaning or get a bigger disk.
    – WGroleau
    Commented Mar 3, 2021 at 16:42
  • If I already have Xcode installed, the install script should recognize that and not download and install the Command Line Tools. I am working with someone who have 256G MacBook Air and a slow internet connection. They did some cleaning, but still have slow internet.
    – chrish
    Commented Mar 3, 2021 at 17:47

3 Answers 3

5

I found the answer by searching the Homebrew Github Closed Issues for "Xcode":

https://github.com/Homebrew/brew/issues/10714

Homebrew requires Xcode Command Line Tools instead of Xcode for several reasons:

  • The CLT contains more SDKs than Xcode - Xcode usually only contains one SDK, and it may be newer than your OS, while the CLT always has a compatible SDK. Having a matching SDK is very important for some formulae.
  • The CLT is in a fixed location /Library/Developer/CommandLineTools while Xcode is not. This matters as some formulae (including Python) bake in paths into files at compile-time - if they pointed to Xcode then it will only work for people who have Xcode installed in the same place.

https://github.com/Homebrew/brew/issues/10714

1
1

Apple's website for downloading developer tools says that "If you use Xcode, these tools are already embedded in the IDE."

So you shouldn't need to install them again.

But, as mentioned in the commments: it's a 460 Mb download. If you don't have space for that, you're not going to have space for HomeBrew, or any of the things it installs.

8
  • After every update of XCode, the next time I use it, it asks me whether I want to install the command line tools. I consider that a bug, and reported such to Apple. And homebrew needs those tools to compile and link the things it installs.
    – WGroleau
    Commented Mar 3, 2021 at 19:35
  • I call it a bug because (1) it contradicts Apple’s claim (see also apple.stackexchange.com/questions/120572/…) and (2) the first time I did it (before bundling), my decision should have been stored and made automatic on the next update.
    – WGroleau
    Commented Mar 3, 2021 at 19:43
  • Xcode has a panel in its Preferences for Locations, which includes the location of the Command Line Tools. Mine is set to inside the application bundle.
    – benwiggy
    Commented Mar 3, 2021 at 20:15
  • 3
    This is not an answer.
    – Kermit
    Commented Nov 2, 2021 at 17:11
  • It requires 4GB disk space after installation
    – Nik
    Commented Apr 3, 2022 at 13:25
1

Homebrew on a Mac can be installed without Xcode Command Line tools. Technically, Git is the only requirement for the initial Homebrew installation. Then, you can use Homebrew to install all packages required by other packages/formulae.

  1. Install a temporary Git independently (see Binary installer).
  2. Download and save install.sh from https://brew.sh. Make the following change to it:
    # USABLE_GIT=/usr/bin/git      # Xcode CLT Git
    USABLE_GIT=/usr/local/bin/git  # Your temporary Git
    
  3. Install Homebrew /bin/bash -c install.sh
  4. Delete your temporary Git.
  5. Install Git with Homebrew brew install git
  6. Modify local file /usr/local/Homebrew/Library/Homebrew/os/mac/xcode.rb:
    def self.installed?
      true  # Override Homebrew's CLT check
      # odeprecated "`MacOS::CLT.installed?` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
      # !version.null?
    end
    

Overriding self.installed? ensures that you can install packages that would otherwise require it (i.e. brew install python). You'll need to version this change to prevent it from being overridden during brew update. For example, using a separate git branch

git checkout -b my-custom-changes              # new branch
git commit -am "bypass Xcode CLT detection"    # commit changes

You must log in to answer this question.

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