76

Homebrew started running brew update automatically before every brew install. This means that I need to wait 10-20 seconds, depending on network speed, every time I want to install a package. This is tedious and unnecessary.

How can I opt out from this behavior, or set it to something saner?

Update: Good news! Homebrew 4, released on February 16 2023, finally fixes this:

brew update will now be run automatically less often (every 24 hours rather than every 5 minutes) and these auto-updates will be much faster as they no longer need to perform the slow git fetch of the huge homebrew/core and homebrew/cask taps’ Git repositories.

mrzool
  • 965

6 Answers6

68

Just prefix your install command with HOMEBREW_NO_AUTO_UPDATE=1, like this:

HOMEBREW_NO_AUTO_UPDATE=1 brew install somepackage

Source: brew manpage

D Schlachter
  • 2,058
13

I just modified /usr/local/bin/brew to add HOMEBREW_NO_AUTO_UPDATE=1 (according to @D Schlachter answer) at the start of the file

6

I personally find pinning/unpinning formulas more useful. For example you install a tool depends on 100 libraries which you don't use.

brew deps someprogram | xargs brew pin

Then you can check your pinned formulas anytime. If you have any problems with the version just unpin.

Not recommended to everyone, to pin all the formulas and manage updates manually:

brew list | xargs brew pin
yet
  • 161
3

To have brew automatically run brew update AFTER installing, I added the following to my bash/zsh environment:

function brew2() {
    HOMEBREW_NO_AUTO_UPDATE=1 brew "$@" && brew update
}

Then to install package x, I do brew2 x, for example brew2 cask install spotmenu. Seems to work.

2

I recommend installing homebrew-autoupdate. Run: brew tap homebrew/autoupdate

This is a script that will automatically run brew update in the background once every 24 hours, or on system boot. Then you can add this line to your ~/.bashrc (or ~/.zshrc) to disable the built-in autoupdate mechanism:

export HOMEBREW_NO_AUTO_UPDATE="1"

You can also configure it to run more frequently in the background, for example every 12 hours (43200 seconds):

brew autoupdate start 43200
ndbroadbent
  • 121
  • 4
1

Here are two other options (one mentioned in one of the other answer's comments) and the other is my own addition:

Option 1

Add export HOMEBREW_NO_AUTO_UPDATE="1" to your ~/.zshrc or ~/.bashrc file, so that it will be always set when running brew install.

Option 2

1. Approach

Create an alias for brew install with the added flag to not auto update like so:

alias brew-install-only="HOMEBREW_NO_AUTO_UPDATE=1 brew install"

And use it like this:

brew-install-only somepackage

2. Approach

If you want to keep the existing syntax of the brew install command, you have to create two aliases like this:

alias brew="brew "
alias install="HOMEBREW_NO_AUTO_UPDATE=1 brew install"

And you would use it just like regular brew install:

brew install somepackage

Taken from this answer.