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.
- Install a temporary Git independently (see Binary installer).
- 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
- Install Homebrew
/bin/bash -c install.sh
- Delete your temporary Git.
- Install Git with Homebrew
brew install git
- 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