Skip to content

fix: guard /usr/local/bin cleanup when directory does not exist on macOS#26

Merged
yashksaini-coder merged 2 commits into
mainfrom
fix/install-script-macos
May 26, 2026
Merged

fix: guard /usr/local/bin cleanup when directory does not exist on macOS#26
yashksaini-coder merged 2 commits into
mainfrom
fix/install-script-macos

Conversation

@yashksaini-coder
Copy link
Copy Markdown
Collaborator

Summary

Fixes #18

On Apple Silicon Macs, /usr/local/bin may not exist. The old cleanup block would attempt sudo rm -f /usr/local/bin/trx even when the directory didn't exist, which could cause unexpected failures under set -e.

Changes

  • Wrapped the old global installation cleanup in a directory existence check: only runs if /usr/local/bin exists and /usr/local/bin/trx exists.

Before

if [ -f "/usr/local/bin/trx" ]; then
    sudo rm -f "/usr/local/bin/trx" || echo "..."
fi

After

if [ -d "/usr/local/bin" ] && [ -f "/usr/local/bin/trx" ]; then
    sudo rm -f "/usr/local/bin/trx" || echo "..."
fi

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>
Copilot AI review requested due to automatic review settings May 26, 2026 05:43
@vercel
Copy link
Copy Markdown

vercel Bot commented May 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
trx Ready Ready Preview, Comment May 26, 2026 6:26am

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

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/bin check 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.

Comment thread install.sh Outdated
Comment on lines 58 to 62
# 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..."
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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>
@yashksaini-coder yashksaini-coder merged commit 5b4ba14 into main May 26, 2026
2 checks passed
@yashksaini-coder yashksaini-coder deleted the fix/install-script-macos branch May 28, 2026 04:22
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.

macOS install script fails: /usr/local/bin not found during TRX installation

2 participants