Skip to content

fix(install): source brew env so non-interactive update finds cargo - #1270

Merged
joelteply merged 1 commit into
canaryfrom
fix/install-brew-path-non-interactive
Jun 20, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/install-brew-path-non-interactive

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Problem (a real self-update reliability bug)

airc update spawns install.sh in a non-interactive shell. On macOS that shell does NOT have /opt/homebrew/bin on PATH — the brew shellenv line that adds it lives in an interactive-only ~/.zprofile. So detect_pkgmgr reported brew-missing and the build died at the cargo is required to build airc probe, even though brew AND cargo were installed at /opt/homebrew/bin.

Caught live on M5: airc update →

! macOS detected but Homebrew not found.
✗ cargo is required to build airc. Install Rust, then re-run install.sh.

This is load-bearing for the daemon self-update mechanism (#1268): auto_update → airc update --auto → install.sh inherits the same non-interactive blind spot, so the mechanism meant to keep nodes current couldn't rebuild on a stock macOS box. Reliability foundation for the mesh.

Fix

ensure_brew_on_path(): on Darwin, if brew isn't already reachable, eval "$(<prefix>/brew shellenv)" from the well-known prefixes (/opt/homebrew/bin, /usr/local/bin) so brew + cargo land on PATH for the rest of the script. Called at the top of ensure_prereqs and (belt-and-suspenders, for the AIRC_SKIP_PREREQS path) at the top of _install_airc_binary. Idempotent; no-op off macOS, when brew is already on PATH, or when brew is genuinely absent (existing installer path still handles that).

Proof

bash -n clean. Built + installed in a scrubbed env -i PATH=/usr/bin:/bin:/usr/sbin:/sbin where it previously bailed:

-> Building Rust CLI: airc
-> Installed airc: /Users/joel/.local/bin/airc
-> Installed.

🤖 Generated with Claude Code

`airc update` spawns install.sh in a non-interactive shell that does NOT
inherit /opt/homebrew/bin on PATH (the `brew shellenv` line lives in an
interactive-only ~/.zprofile). On macOS this made detect_pkgmgr report
"brew-missing" and the build die at the "cargo is required" probe — even
though brew AND cargo were installed at /opt/homebrew/bin. Self-update
(airc-daemon auto_update -> airc update --auto -> install.sh) inherits the
same blind spot, so the very mechanism meant to keep nodes current could
not rebuild on a stock macOS box.

Add ensure_brew_on_path(): on Darwin, if brew isn't already reachable,
source `brew shellenv` from the well-known prefixes (/opt/homebrew/bin,
/usr/local/bin) so brew + cargo land on PATH for the rest of the script.
Called at the top of ensure_prereqs and (belt-and-suspenders, for the
AIRC_SKIP_PREREQS path) at the top of _install_airc_binary. Idempotent,
no-op off macOS / when brew already on PATH / when brew is genuinely
absent (the existing installer path still handles that case).

Proven: install.sh now builds + installs in a scrubbed
PATH=/usr/bin:/bin:/usr/sbin:/sbin env where it previously bailed.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@joelteply
joelteply merged commit 28829f9 into canary Jun 20, 2026
7 checks passed
@joelteply
joelteply deleted the fix/install-brew-path-non-interactive branch June 20, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant