Homebrew is a free and open-source package management system for macOS users. It gives you a flexible way to install the UNIX tools Apple doesn’t include on macOS. The package management covers installation, searching, updating, cleanup and complete uninstallation. If you’re a frequent user of brew command line tool you must have noted that it performs update every time a command to install formula is executed.

See the example below to install ranger formula:

$ brew install ranger
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> Updated Casks
browserosaurus

==> Downloading https://ranger.github.io/ranger-1.9.3.t
....

To prevent this update whenever you run a brew command, pass 1 to the HOMEBREW_NO_AUTO_UPDATE environment variable.

HOMEBREW_NO_AUTO_UPDATE=1 brew install 

This is a one time operation. To make it a permanent configuration set the variable in your .bashrc or .zshrc file depending on the shell you use.

--- Bash ---
$ vim ~/.bashrc
export HOMEBREW_NO_AUTO_UPDATE=1

--- Zsh ---
$ vim ~/.zshrc
export HOMEBREW_NO_AUTO_UPDATE=1

Source the shell configuration file:

$ source ~/.bashrc or source ~/.zshrc

Now try and installation of formula to confirm the setting was effective.

$ brew install iproute2mac
==> Downloading https://github.com/brona/iproute2mac/releases/download/v1.2.3/iproute2mac-1.2.3.tar.gz
Already downloaded: /Users/jkmutai/Library/Caches/Homebrew/downloads/fdb133eaa8f1346a259295ba9aa22ab568e0dd6b6506cafab6891ae6e31fcf84--iproute2mac-1.2.3.tar.gz🍺  /usr/local/Cellar/iproute2mac/1.2.3: 6 files, 22.5KB, built in 2 seconds

We can confirm no update was attempted.