fix: guard /usr/local/bin cleanup when directory does not exist on macOS#26
Conversation
On Apple Silicon Macs /usr/local/bin may not exist. Only attempt to remove an old global installation if the directory itself is present, preventing the cleanup block from erroring under set -e. Closes #18 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent failures in install.sh on macOS systems where /usr/local/bin may not exist by guarding the “old global install cleanup” step behind a directory existence check.
Changes:
- Adds a
-d /usr/local/bincheck before attempting to remove/usr/local/bin/trx. - Updates the comment describing why the guard is needed (macOS directory absence).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Also check common global path just in case (directory may not exist on macOS) | ||
| if [ -d "/usr/local/bin" ] && [ -f "/usr/local/bin/trx" ]; then | ||
| echo "Existing global installation found at /usr/local/bin/trx." | ||
| echo "Removing old global version..." | ||
| sudo rm -f "/usr/local/bin/trx" || echo "Failed to remove /usr/local/bin/trx. Continuing..." |
There was a problem hiding this comment.
Good catch. The comment and messages have been updated to make it explicit that this block is legacy-cleanup only — it removes any binary left in /usr/local/bin by an older version of the script. The actual install target remains INSTALL_DIR ($HOME/.local/bin) and the download/install steps that follow are unchanged. Fixed in the latest commit.
… target The comment and messages now make it explicit that this block only removes an old binary left by a previous version of the script. The real install target remains INSTALL_DIR ($HOME/.local/bin), so this cleanup cannot interfere with the installation step that follows. Addresses Copilot review comment on PR #26. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Fixes #18
On Apple Silicon Macs,
/usr/local/binmay not exist. The old cleanup block would attemptsudo rm -f /usr/local/bin/trxeven when the directory didn't exist, which could cause unexpected failures underset -e.Changes
/usr/local/binexists and/usr/local/bin/trxexists.Before
After