1

Why does brew attempt to download a dependency (and fail) when that dependency is already installed?

I'm trying to install a python bottle from homebrew on a system that does not have Internet access.

brew reinstall --debug --verbose --skip-cask-deps build/deps/python-3.11.catalina.bottle.tar.gz

The above command fails when brew tries (and fails) to access the Internet to download one of the dependencies (mpdecimal)

==> Fetching dependencies for [email protected]: mpdecimal, ca-certificates, [email protected], readline, sqlite and xz
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromDefaultNameLoader): loading mpdecimal
==> Fetching mpdecimal
/usr/bin/env /usr/local/Homebrew/Library/Homebrew/shims/shared/curl --disable --config /Users/maltfield/sandbox/buskill-app/build/deps/.curlrc --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.2.11\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 10.15.7\)\ curl/7.64.1 --header Accept-Language:\ en --fail --location --silent --head https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-4.0.0.tar.gz
==> Downloading https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-4.0.0.tar.gz
/usr/bin/env /usr/local/Homebrew/Library/Homebrew/shims/shared/curl --disable --config /Users/maltfield/sandbox/buskill-app/build/deps/.curlrc --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.2.11\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 10.15.7\)\ curl/7.64.1 --header Accept-Language:\ en --fail --location --silent --head https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-4.0.0.tar.gz
/usr/bin/env /usr/local/Homebrew/Library/Homebrew/shims/shared/curl --disable --config /Users/maltfield/sandbox/buskill-app/build/deps/.curlrc --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.2.11\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 10.15.7\)\ curl/7.64.1 --header Accept-Language:\ en --fail --remote-time --output /Users/maltfield/sandbox/buskill-app/build/deps/downloads/72a206df09e9c8bd3f7b24b1dc25e15971fb05aab8c1576b95b73df2ae463ca0--mpdecimal-4.0.0.tar.gz.incomplete --location https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-4.0.0.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
curl: (28) Connection timed out after 1000 milliseconds
Error: Failed to download resource "mpdecimal"
Download failed: https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-4.0.0.tar.gz

However, when I check the system, I see that mpdecimal is already installed. In fact, all of the dependencies are all already installed!

bash-3.2$ brew list | grep -iE 'mpdecimal|ca-certificates|openssl|readline|sqlite|xz'
ca-certificates
mpdecimal
[email protected]
readline
sqlite
xz
bash-3.2$ 

Why is brew trying to fetch a dependency that's already installed, and how do I tell it to stop trying to do that (or, at least, proceed with installing the bottle anyway)?

1 Answer 1

0

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

% cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/m
% mv mpdecimal.rb mpdecimal.rb.$(date "+%Y%m%d_%H%M%S")
% cp /usr/local/Cellar/mpdecimal/*/.brew/mpdecimal.rb .
% 

% cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/c
% mv ca-certificates.rb ca-certificates.rb.$(date "+%Y%m%d_%H%M%S")
% cp /usr/local/Cellar/ca-certificates/*/.brew/ca-certificates.rb .
% 

% cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/o
% mv [email protected] [email protected].$(date "+%Y%m%d_%H%M%S")
% cp /usr/local/Cellar/[email protected]/*/.brew/[email protected] .
% 

% cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/r
% mv readline.rb readline.rb.$(date "+%Y%m%d_%H%M%S")
% cp /usr/local/Cellar/readline/*/.brew/readline.rb .
% 

% cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/s
% mv sqlite.rb sqlite.rb.$(date "+%Y%m%d_%H%M%S")
% cp /usr/local/Cellar/sqlite/*/.brew/sqlite.rb .
% 

% cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/x
% mv xz.rb xz.rb.$(date "+%Y%m%d_%H%M%S")
% cp /usr/local/Cellar/xz/*/.brew/xz.rb .
% 

Now attempting to install the python bottle works, without failing at trying to download depends that are already installed.

For more info, see:

1
  • This might not work if the package you are installing depends on functionality available in mpdecimal 4.0.0 but not in mpdecimal 2.5.1.
    – nohillside
    Commented Apr 30 at 6:02

You must log in to answer this question.

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