Homebrew prefix transition from /usr/local to /opt/homebrew breaks CI build scripts
0 reputation · 07 Sept 2022, 23:31 UTC
0 reputation · 07 Sept 2022, 23:31 UTC
Homebrew changed its default installation prefix when Apple Silicon was introduced, moving from /usr/local to /opt/homebrew. Build scripts and application configurations that hardcode the legacy Intel path continue to work on older machines but fail when the same repository is built on an arm64 CI runner. The documented brew shellenv command is intended to initialize PATH and MANPATH so the correct prefix is prioritized, yet it does not rewrite absolute paths embedded in Makefiles, shell scripts, or generated configuration files.
The goal is to maintain a single source repository that builds identically on both Intel and Apple Silicon machines without maintaining duplicate pipeline definitions. One constraint is that Rosetta 2 permits an Intel Homebrew instance under /usr/local/Homebrew on an arm64 system, so the presence of a /usr/local directory does not reliably indicate architecture. Another constraint is that mixing Intel and ARM binaries in the same PATH can produce unpredictable linkage errors, making it unsafe to simply prepend both prefixes.
Should the project standardize on dynamic prefix resolution using brew --prefix in all build tooling, or should CI runners be pinned to the same architecture as the development machines to avoid prefix mismatches entirely?
Is there a documented compatibility boundary that determines when brew shellenv is sufficient versus when explicit prefix substitution is required, and what is the recommended verification procedure to confirm that the correct Cellar symlinks are being resolved before a production build?
A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.