fix(macos.sh): trust brew taps before tapping them (#28702)

* fix(macos.sh): trust brew taps before tapping them

Recent Homebrew validates every formula of a tap while tapping it. On
Homebrew 6.0+ loading a formula from an untrusted tap is refused, so
`brew tap osx-cross/arm` and `brew tap PX4/px4` now fail with
"Cannot tap ...: invalid syntax in tap!" because `brew trust` only ran
afterwards. Without the PX4/px4 tap, `brew install` aborts on `fastdds`
before pouring any package, ccache included, and the macOS CI job dies
with `ccache: command not found`. main has been red since 2026-09-14.

Run `brew trust` before `brew tap`; it accepts taps that are not
installed yet.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(macos.sh): trust osrf/simulation tap before tapping it

Same ordering problem as the toolchain taps: with Homebrew 6.0+ tapping
an untrusted tap fails, so there is no tap clone to apply the
gz-tap-pin.txt pin to. The later install of
osrf/simulation/gz-harmonic then taps it implicitly at HEAD, silently
skipping the pin and risking Gazebo building from source.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Julian Oes <julian@oes.ch>

* fix(macos.sh): set -e to abort on first failure

The script kept going after a failed `brew tap` or `brew install`, so
the macOS CI job only failed much later with `ccache: command not
found`, far away from the actual cause.

Add `set -e`. Commands that are allowed to fail (`brew uninstall flock`
on a machine without it, `brew doctor` warnings, fetching the gz tap pin
whose failure is already handled by the following checkout) get an
explicit `|| true`.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Signed-off-by: Julian Oes <julian@oes.ch>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Julian Oes <julian@oes.ch>
This commit is contained in:
authored and GitHub committed 2026-09-15 11:17:37 +02:00
1 parent e880f1cd79
commit 3309f497d8
1 file changed
+25 -17
+25 -17
View File
@@ -16,6 +16,9 @@
## behind meta-formulae. See PX4/homebrew-px4#104 for background.
##
# Abort on the first failing command.
set -e
# script directory
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
@@ -50,7 +53,7 @@ fi
# "installed from the discoteq/discoteq tap but you are trying to install
# it from homebrew/core" on machines that still have it tapped.
if brew tap | grep -q '^discoteq/discoteq$'; then
brew uninstall flock 2>/dev/null
brew uninstall flock 2>/dev/null || true
brew untap discoteq/discoteq
fi
@@ -60,13 +63,14 @@ fi
#
# - osx-cross/arm: arm-gcc-bin@13 (ARM cross-compiler)
# - PX4/px4: fastdds, genromfs, kconfig-frontends (PX4-specific)
brew tap osx-cross/arm
brew tap PX4/px4
#
# Homebrew 6.0+ refuses to load formulae from third-party taps unless they
# are explicitly trusted ("Refusing to load formula ... from untrusted tap").
# Trust each tap non-interactively before installing from it. Without this,
# `brew install` aborts before pouring any package (including ccache).
# are explicitly trusted ("Refusing to load formula ... from untrusted tap"),
# and recent versions validate every formula of a tap while tapping it. An
# untrusted tap therefore fails with "Cannot tap ...: invalid syntax in tap!",
# so the taps must be trusted *before* they are tapped. `brew trust` works on
# a tap that is not installed yet. Without the taps, `brew install` aborts
# on the first PX4/px4 formula before pouring any package (including ccache).
# `brew trust` only exists on Homebrew 6.0+; guard it so older versions,
# which don't gate untrusted taps, skip it silently.
if brew trust --help &> /dev/null; then
@@ -74,6 +78,9 @@ if brew trust --help &> /dev/null; then
brew trust PX4/px4
fi
brew tap osx-cross/arm
brew tap PX4/px4
# Package list. This replaces the px4-dev meta-formula, which is kept
# as a deprecated no-op upstream. See PX4/homebrew-px4 for history.
PX4_BREW_PACKAGES=(
@@ -95,7 +102,7 @@ PX4_BREW_PACKAGES=(
if [[ $REINSTALL_FORMULAS == "--reinstall" ]]; then
echo "[macos.sh] Re-installing PX4 toolchain dependencies"
brew doctor
brew doctor || true # warnings are informational here
brew reinstall "${PX4_BREW_PACKAGES[@]}"
else
echo "[macos.sh] Installing PX4 toolchain dependencies"
@@ -130,6 +137,15 @@ if [[ $INSTALL_SIM == "--sim-tools" ]]; then
# px4-dev precedent.
#
# osrf/simulation: gz-harmonic (Gazebo Harmonic meta-formula)
#
# Trust before tapping, same as the toolchain taps above. Tapping an
# untrusted tap fails, which leaves no tap clone to pin below; the
# later `brew install osrf/simulation/gz-harmonic` then taps it
# implicitly at HEAD and the pin is silently skipped.
if brew trust --help &> /dev/null; then
brew trust osrf/simulation
fi
brew tap osrf/simulation
# OSRF drops the gz bottle blocks within minutes of a breaking
@@ -143,7 +159,7 @@ if [[ $INSTALL_SIM == "--sim-tools" ]]; then
echo "[macos.sh] Pinning osrf/simulation to ${GZ_TAP_PIN}"
# brew taps are shallow clones, so the pinned commit has to be
# fetched by SHA before it can be checked out.
git -C "$GZ_TAP_DIR" fetch --quiet origin "$GZ_TAP_PIN" 2>/dev/null
git -C "$GZ_TAP_DIR" fetch --quiet origin "$GZ_TAP_PIN" 2>/dev/null || true
if git -C "$GZ_TAP_DIR" checkout --quiet "$GZ_TAP_PIN"; then
# `brew update` walks local taps and would reset the pin.
# homebrew-core resolves through the JSON API, not this
@@ -155,14 +171,6 @@ if [[ $INSTALL_SIM == "--sim-tools" ]]; then
fi
fi
# Homebrew 6.0+ refuses to load formulae from untrusted third-party
# taps (see the toolchain trust block above). Without this, the
# gz-harmonic install aborts and the script still exits successfully,
# leaving the simulation stack silently missing.
if brew trust --help &> /dev/null; then
brew trust osrf/simulation
fi
# opencv@4: the unversioned formula is OpenCV 5, which PX4-OpticalFlow
# does not build against.
PX4_SIM_BREW_PACKAGES=(