2

The brew installer does a git clone of some very large repositories, which is slow.

It doesn't use:

In a CI environment where brew update is not needed, how can the brew installer be forced to use a shallow clone to speed up the operation?

torek
  • 448,244
  • 59
  • 642
  • 775
John Vandenberg
  • 474
  • 6
  • 16

1 Answers1

1

The installer can be hacked to use shallow clone. Then an error occurs when the installer tries to run brew update. So the steps are fetch the installer script, force using shallow clone, and remove the use of brew update.

wget -c https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
sed -i 's:"git" "fetch":"git" "fetch" "--depth" "1":' ./install.sh
sed -i '/"update" "--force"/d' ./install.sh

When doing this, be sure to use HOMEBREW_NO_AUTO_UPDATE=1 and do not use brew update.

To do the install, run

HOMEBREW_NO_AUTO_UPDATE=1 bash ./install.sh
John Vandenberg
  • 474
  • 6
  • 16
  • Aside: having brew using a shallow clone of depth n>1 (2 or more) by default might also help, and not require this sort of thing. GitHub might still object as I think they have special optimization hacks for "first full clone" though. – torek May 31 '22 at 06:05