Skip to content

fix(build): safely append Homebrew paths to avoid overriding user toolchains#68

Merged
solderzzc merged 1 commit intomainfrom
fix/build-sh-path-append
Apr 20, 2026
Merged

fix(build): safely append Homebrew paths to avoid overriding user toolchains#68
solderzzc merged 1 commit intomainfrom
fix/build-sh-path-append

Conversation

@solderzzc
Copy link
Copy Markdown
Member

Refines the previous PATH injection in build.sh based on PR review. Instead of globally prepending the Homebrew binary directories, they are now safely appended to the PATH only if they exist and are not already present. This ensures that any custom user toolchains (like explicit cmake or swift paths) take priority while safely falling back to native Homebrew paths on Apple Silicon.

Copilot AI review requested due to automatic review settings April 20, 2026 02:59
@solderzzc solderzzc merged commit 1724a48 into main Apr 20, 2026
2 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates build.sh PATH handling so Homebrew tool directories are appended only when present and not already included, avoiding unintentional precedence over user-provided toolchains.

Changes:

  • Replace unconditional Homebrew PATH prepending with conditional PATH appends for /opt/homebrew/bin.
  • Add conditional PATH append for /usr/local/bin to support Intel Homebrew layouts while preserving existing PATH precedence.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread build.sh
Comment on lines +6 to +9
export PATH="$PATH:/opt/homebrew/bin"
fi
if [[ ":$PATH:" != *":/usr/local/bin:"* ]] && [ -d "/usr/local/bin" ]; then
export PATH="$PATH:/usr/local/bin"
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appending with export PATH="$PATH:/opt/homebrew/bin" (and similarly for /usr/local/bin) will introduce an empty PATH element if $PATH is empty/unset, which makes the current working directory searchable (PATH=":/opt/homebrew/bin"). Consider using a safe append pattern (e.g., only add the : when $PATH is non-empty) to avoid this security/behavior risk.

Suggested change
export PATH="$PATH:/opt/homebrew/bin"
fi
if [[ ":$PATH:" != *":/usr/local/bin:"* ]] && [ -d "/usr/local/bin" ]; then
export PATH="$PATH:/usr/local/bin"
export PATH="${PATH:+$PATH:}/opt/homebrew/bin"
fi
if [[ ":$PATH:" != *":/usr/local/bin:"* ]] && [ -d "/usr/local/bin" ]; then
export PATH="${PATH:+$PATH:}/usr/local/bin"

Copilot uses AI. Check for mistakes.
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.

2 participants