Check the version with brew list --versions and you can update your formula cache to prevent it from updating
Why?
By default brew list doesn’t show you the versions installed. Add --versions to see that
bash-3.2$ brew list --versions | grep -iE 'mpdecimal|ca-certificates|openssl|readline|sqlite|xz'
ca-certificates 2022-10-11
mpdecimal 2.5.1
[email protected] 1.1.1q
readline 8.2.1
sqlite 3.39.4
xz 5.2.7
bash-3.2$
In this case, you can see that you have mpdecimal 2.5.1 installed, but the output from the brew reinstall above shows that its trying to download mpdecimal 4.0.0.
Fix it
This is terrible and I only figured it out by trial-and-error, but apparently brew doesn’t try to install the version required by the bottle (I couldn’t see that defined anywhere in the bottle itself) — but it just tries to download the latest version based on the formulas you have cached on your system.
The homebrew formulas are a collection of .rb files stored in Homebrew’s homebrew-core github repo:
On your system, this repo is checked-out by Homebrew here:
maltfield@host m % ls -lah /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
total 120
drwxr-xr-x 17 maltfield admin 544B Mar 30 23:19 .
drwxr-xr-x 5 maltfield admin 160B Mar 30 23:19 ..
drwxr-xr-x 15 maltfield admin 480B Mar 30 23:19 .git
drwxr-xr-x 8 maltfield admin 256B Mar 30 23:19 .github
drwxr-xr-x 277 maltfield admin 8.7K Mar 30 23:19 Aliases
-rw-r--r-- 1 maltfield admin 1.4K Mar 30 23:19 CODEOWNERS
-rw-r--r-- 1 maltfield admin 5.5K Mar 30 23:19 CONTRIBUTING.md
drwxr-xr-x 29 maltfield admin 928B Mar 30 23:19 Formula
-rw-r--r-- 1 maltfield admin 1.3K Mar 30 23:19 LICENSE.txt
-rw-r--r-- 1 maltfield admin 479B Mar 30 23:19 README.md
drwxr-xr-x 20 maltfield admin 640B Mar 30 23:19 audit_exceptions
drwxr-xr-x 5 maltfield admin 160B Mar 30 23:19 cmd
-rw-r--r-- 1 maltfield admin 5.3K Mar 30 23:19 formula_renames.json
-rw-r--r-- 1 maltfield admin 20K Mar 30 23:19 pypi_formula_mappings.json
drwxr-xr-x 9 maltfield admin 288B Mar 30 23:19 style_exceptions
-rw-r--r-- 1 maltfield admin 2.4K Mar 30 23:19 synced_versions_formulae.json
-rw-r--r-- 1 maltfield admin 1.1K Mar 30 23:19 tap_migrations.json
maltfield@host m %
Fortunately, if you already have the dependencies installed (Homebrew installs them to /usr/local/Cellar, then you can just overwrite these .rb files with the ones that you have installed, and it will make brew reinstall skip the attempt to download updates to the depends.
In my case, for the python-3.11 bottle, I executed the following
maltfield@host ~ % cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/m
maltfield@host m % mv mpdecimal.rb mpdecimal.rb.$(date "+%Y%m%d_%H%M%S")
maltfield@host m % cp /usr/local/Cellar/mpdecimal/*/.brew/mpdecimal.rb .
maltfield@host m %
maltfield@host ~ % cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/c
maltfield@host c % mv ca-certificates.rb ca-certificates.rb.$(date "+%Y%m%d_%H%M%S")
maltfield@host c % cp /usr/local/Cellar/ca-certificates/*/.brew/ca-certificates.rb .
maltfield@host c %
maltfield@host c % cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/o
maltfield@host o % mv [email protected] [email protected].$(date "+%Y%m%d_%H%M%S")
maltfield@host o % cp /usr/local/Cellar/[email protected]/*/.brew/[email protected] .
maltfield@host o %
maltfield@host o % cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/r
maltfield@host r % mv readline.rb readline.rb.$(date "+%Y%m%d_%H%M%S")
maltfield@host r % cp /usr/local/Cellar/readline/*/.brew/readline.rb .
maltfield@host r %
maltfield@host r % cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/s
maltfield@host s % mv sqlite.rb sqlite.rb.$(date "+%Y%m%d_%H%M%S")
maltfield@host s % cp /usr/local/Cellar/sqlite/*/.brew/sqlite.rb .
maltfield@host s %
maltfield@host s % cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/x
maltfield@host x % mv xz.rb xz.rb.$(date "+%Y%m%d_%H%M%S")
maltfield@host x % cp /usr/local/Cellar/xz/*/.brew/xz.rb .
maltfield@host x %
Now attempting to install the python bottle works, without failing at trying to download depends that are already installed.
For more info, see:
