Skip to content

fix(install): preserve existing binary when installation fails - #5684

Open
harshvarudkar wants to merge 2 commits into
github:mainfrom
harshvarudkar:fix/atomic-installer-upgrades
Open

harshvarudkar wants to merge 2 commits into
github:mainfrom
harshvarudkar:fix/atomic-installer-upgrades

Conversation

@harshvarudkar

Copy link
Copy Markdown

An interrupted or failed archive extraction currently overwrites $PREFIX/bin/copilot in place, replacing a working installation with a partial executable.

Stage the replacement in a temporary directory on the destination filesystem, check that it is a non-empty regular file, and set its executable permissions before renaming it into place. Clean up the staging directory on exit. Reject directory destinations, including symlinks to directories, so mv cannot silently install inside them.

Adds 15 offline regression cases covering extraction failure and termination, permission and rename failures, staging-directory creation failure, invalid archive contents, fresh installs, upgrades, paths containing spaces, and existing symlink/directory destinations. The tests use local fixtures and do not download or run Copilot. A path-filtered workflow runs the suite on Linux and macOS.

Validation:

@harshvarudkar
harshvarudkar requested review from a team and an adaptive review from Copilot December 5, 2026 17:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The workflow passes tests/install.sh as an argument to install.sh, leaving the test script unchecked; each script needs a separate bash -n invocation.

1 open issue
What changed in this PR

Protects existing Copilot CLI installations by staging and validating replacements before an atomic rename.

Changes:

  • Adds staging cleanup, executable validation, and directory-destination rejection.
  • Adds 15 offline regression cases covering successful installs and failure recovery.
  • Adds path-filtered Linux and macOS CI checks.
File Description
tests/​install.sh Adds offline installer regression tests.
install.sh Stages replacements to preserve existing binaries on failure.
.github/​workflows/​test-install.yml Runs syntax checks and regression tests on Linux and macOS.

Review effort: Balanced (adaptive)

Comment thread .github/workflows/test-install.yml Resolved
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