70

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.

6 Answers 6

64

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

HOMEBREW_NO_AUTO_UPDATE=1 brew install somepackage

Source: brew manpage

12

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

3
  • 31
    Why not just add export HOMEBREW_NO_AUTO_UPDATE=1 to your .bashrc?
    – cpcallen
    Commented Nov 5, 2019 at 15:29
  • 4
    this and/or @cpcallen's comment above should be marked as the correct answer.
    – Rob
    Commented Nov 24, 2019 at 20:10
  • 6
    Why is this not the default setting? Who says, let me install something and while I am at it upgrade the other 50 things (because that certainly won't break anything) Commented Aug 14, 2021 at 2:07
5

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
1
  • 4
    What does this have to do with homebrew updating itself?
    – philraj
    Commented Jul 8, 2020 at 14:32
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
  • 2
    Why want homebrew to update everything before or after install at all? "If something is working, don't fix it", yet brew is doing it. Why would it be updating mitmproxy when I only want to install mysql-client? Commented Dec 20, 2020 at 23:35
  • The best thing to do, imo, would be to auto-update everything in the background, the way apps autoupdate on phones nowadays. Something like this: apple.stackexchange.com/a/206474/308005 Commented Jan 28, 2021 at 19:02
1

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
1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Jun 6, 2022 at 21:16
0

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.

You must log in to answer this question.

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