How do I avoid compilation when running brew install

My internet connection sometimes drops packets (its a 4G connection), so when I download stuff sometimes it fails.

So when doing "brew install" on something this occasionally happens:

==> Installing ffmpeg dependency: libogg
==> Downloading https://homebrew.bintray.com/bottles/libogg-1.3.4.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/0a/0a03b8a7307aeac70762fd4ee9837fff4ed523c34063a6aec52c5cf34c54695f?__gda__=exp=15884933

curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to akamai.bintray.com:443
Error: Failed to download resource "libogg"
Download failed: https://homebrew.bintray.com/bottles/libogg-1.3.4.catalina.bottle.tar.gz
Warning: Bottle installation failed: building from source.
==> Downloading https://downloads.xiph.org/releases/ogg/libogg-1.3.4.tar.gz
...

That SSL error is caused by a dropped packet. What brew should do here is preferable just try downloading again. What it does is however try to compile from source. That of course delays stuff tremendously. I would rather have brew just fail if this happens, so I can just rerun the command, and (probably) get the bottle the second time.

Is there a way to do this?


Solution 1:

From man brew

HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK
              If set, fail on the failure of installation from a bottle rather
              than falling back to building from source.

So run:

export HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK=1

Then run the command again.