Repository navigation
Conversation
…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)
|
How can we speed up things here? :) |
Author
|
Hey! Yeah, mostly just waiting on CI at this point the workflows need a maintainer to approve them before anything runs. That's really the only blocker on my end. |
Member
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2. — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #37055
Type of change
What does this PR do?
Ran into this while trying to upgrade on Windows — the command says it worked but nothing actually changed. Spent a while figuring out what was happening.
The problem is in how
upgradeCurlworks. It grabs a bash script from opencode.ai/install and runs it, which then tries tomvthe new binary over the one that's currently running. On Linux this is fine, but Windows won't let you overwrite a running executable, so the mv just fails silently. The script doesn't catch this and reports success anyway.The fix adds a separate path for Windows in
upgradeCurl. When it detectsprocess.platform === "win32", it callsupgradeCurlWindowsinstead of running the bash script. This new function:curl.exedirectly (no bash script involved).oldThe batch script loops with
move /yuntil it succeeds, so it doesn't matter if the user is still in a session — it just waits until the process is gone.I know this pattern might look a bit hacky with the batch file and retry loop, but I couldn't find a cleaner way to handle a locked executable on Windows. Open to suggestions if there's a better approach.
Supersedes #37051 — that one got closed because I didn't fill out the template properly.
How did you verify your code works?
Tested on Windows 10. Built locally, ran
opencode upgradewhile in a session, then checked that the batch script was actually running in the background. After exiting, confirmed the binary got swapped by runningopencode --versionand checking the file timestamp. Also verified the temp files got cleaned up after the swap finished.One thing I'm not 100% sure about — I only tested on Windows 10, not 11. The mechanism should be identical but I haven't verified that personally.
Screenshots / recordings
Not a UI change, so nothing to show here.
Checklist