Skip to content

fix(installation): handle Windows upgrade by scheduling binary replacement - #37051

Closed
loisekk wants to merge 2 commits into
anomalyco:devfrom
loisekk:fix/windows-upgrade
Closed

loisekk wants to merge 2 commits into
anomalyco:devfrom
loisekk:fix/windows-upgrade

Conversation

@loisekk

@loisekk loisekk commented Jul 15, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #37055

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

opencode upgrade uses the curl method which runs a bash install script from https://opencode.ai/install. This script downloads the new binary and tries to mv it over the running one. Windows locks running executables, so the mv fails silently and the upgrade reports success without actually replacing the binary.

This fix adds a Windows-specific upgrade path (upgradeCurlWindows) that:

  1. Downloads the zip using curl.exe directly
  2. Extracts it to a temp directory
  3. Renames the current binary to .old
  4. Spawns a background batch script that waits for the process to exit, then replaces the binary and cleans up

The batch script retries the move in a loop, so it handles both normal exit and cases where the user stays in the session longer.

How did you verify your code works?

  • Tested on Windows 11 with opencode 1.17.0
  • Ran opencode upgrade, confirmed it downloads and extracts the new version
  • Confirmed "Upgrade scheduled" message appears
  • Exited opencode, verified binary was replaced
  • Ran opencode --version to confirm new version

Screenshots / recordings

N/A - CLI change, no UI modification.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…ement

On Windows, the 'curl' upgrade method runs a bash install script that
tries to mv the new binary over the running one. Windows locks running
executables, so the mv fails silently and the upgrade reports success
without actually replacing the binary.

This fix adds a Windows-specific upgrade path that:
1. Downloads the zip using curl.exe
2. Extracts it to a temp directory
3. Renames the current binary to .old
4. Spawns a background batch script that waits for the process to exit,
   then replaces the binary and cleans up

The batch script retries the move in a loop, so it handles both cases:
- User exits opencode normally
- User is still in the session (waits until they exit)
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Jul 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Jul 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: opencode upgrade fails silently on Windows - binary never replaced

1 participant