I have observed on my macOS 12.3 (21E230) for quite some time that Homebrew very often reinstalls the entire PHP package during an upgrade process and thus recompiles it as well.
> brew upgrade
(…)
==> No outdated dependents to upgrade!
==> Checking for dependents of upgraded formulae...
Disable this behaviour by setting HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Reinstalling 1 dependent with broken linkage from source:
php
==> Downloading https://www.php.net/distributions/php-8.1.4.tar.xz
######################################################################## 100.0%
==> Reinstalling php
==> Patching
==> ./buildconf --force
==> ./configure --prefix=/usr/local/Cellar/php/8.1.4 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc/php/8.1 --w
==> make
==> make install
==> /usr/local/Cellar/php/8.1.4/bin/pear config-set php_ini /usr/local/etc/php/8.1/php.ini system
==> /usr/local/Cellar/php/8.1.4/bin/pear config-set php_dir /usr/local/share/pear system
(…)
I suspect some misconfiguration in this undesirable behavior, but can't see what exactly is wrong. I don't assume that PHP pushes near-weekly updates to the Homebrew formulas and therefore triggers the time-consuming recompilation for every tiny patch.
Analysis
The value of HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK
is on the default setting. I don't suspect that the default value provokes this unnecessary recompilation. The man page describes this setting as: "Unless HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK is set, brew upgrade or brew reinstall will be run for outdated dependents and dependents with broken linkage, respectively". I don't see, why this should cause the recompiling: php
is linked well.
> brew link php
Warning: Already linked: /usr/local/Cellar/php/8.1.4
To relink, run:
brew unlink php && brew link php
I uninstalled and deleted PHP in all existing versions - and then reinstalled.
I don't understand why brew info php
shows an entry for version 8.1.3_1.reinstall
. I fear that this is causing the problem.
> brew info php
php: stable 8.1.4 (bottled), HEAD
General-purpose scripting language
https://www.php.net/
/usr/local/Cellar/php/8.1.3_1.reinstall (263 files, 32.8MB)
Built from source
/usr/local/Cellar/php/8.1.4 (507 files, 79.9MB) *
Built from source on 2022-03-24 at 13:43:37
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/php.rb
License: PHP-3.01
==> Dependencies
Build: httpd ✔, pkg-config ✔
Required: apr ✔, apr-util ✔, argon2 ✔, aspell ✔, autoconf ✔, curl ✔, freetds ✔, gd ✔, gettext ✔, gmp ✔, icu4c ✔, krb5 ✔, libpq ✔, libsodium ✔, libzip ✔, oniguruma ✔, openldap ✔, openssl@1.1 ✔, pcre2 ✔, sqlite ✔, tidy-html5 ✔, unixodbc ✔
==> Options
--HEAD
Install HEAD version
(…)
brew config
shows nothing remarkable:
HOMEBREW_VERSION: 3.4.3-45-gb1577d3
ORIGIN: https://github.com/Homebrew/brew
HEAD: b1577d34719c04f57e83bcf4cc8f3de1146e1506
Last commit: 4 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: f27ca5adf5867595bbfd0ce9c5e2c0c8247673bd
Core tap last commit: 36 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_CORE_GIT_REMOTE: https://github.com/Homebrew/homebrew-core
HOMEBREW_MAKE_JOBS: 12
Homebrew Ruby: 2.6.8 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: dodeca-core 64-bit kabylake
Clang: 13.1.6 build 1316
Git: 2.35.1 => /usr/local/bin/git
Curl: 7.79.1 => /usr/bin/curl
macOS: 12.3-x86_64
CLT: 13.3.0.0.1.1645755326
Xcode: N/A