GeezerVison is showing github.com — fix(cli): normalize Windows PWD in run command by zpzjzj · Pull Request #61619 · anomalyco/opencode
Conversation
zpzjzj
commented
Nov 4, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Issue for this PR
Fixes #61603.
Type of change
What does this PR do?
Normalize the shell's PWD with the existing FSUtil.windowsPath() before the noninteractive run command or interactive mini entry calls native process.chdir(). Git Bash supplies /c/... on Windows; the native process needs C:/.... The converter leaves non-Windows paths unchanged and does not resolve symlinks, preserving logical POSIX PWD behavior. The run fix targets packages/cli/src/run/run.ts, following the removal of the V1 bridge in #61911; mini applies the same conversion in its existing localDirectory().
Add subprocess regressions that call the real runNonInteractive and runMini entries with a working directory containing spaces. They supply MSYS PWD on Windows and native PWD elsewhere, then verify the selected directory canonically. A deliberately malformed endpoint stops run before server/model access. For mini, only the isolated child's stdin/stdout TTY flags are simulated; invalid model syntax stops execution after directory selection, before rendering the UI or making server/model requests. No platform overrides or test-only production exports are added.
Standalone reproduction
In Windows PowerShell with OpenCode v2.2.5 on PATH:
New-Item -ItemType Directory -Force C:\Temp\opencode-pwd-repro | Out-Null
Set-Location C:\Temp\opencode-pwd-repro
$env:PWD = '/c/Temp/opencode-pwd-repro'
opencode run --format json -- hello
The existing directory is rejected with Failed to change directory to /c/Temp/opencode-pwd-repro, before any model call. Setting $env:PWD = (Get-Location).Path gets past that directory check. Git Bash normally supplies the MSYS-style value; PowerShell makes it explicit here.
How did you verify your code works?
- Reproduced the published v2.2.5 directory failure on Windows Server 2025. With the same executable, workspace and local mock provider, converting PWD to a Windows path allowed startup and the minimal prompt to complete. OpenCode 1.19.5 passed without the workaround. Details are in cli: v1 run bridge fails on Windows Git Bash PWD (/c/...) #61603.
- With pinned Bun 1.4.4,
bun test --timeout 30000 test/run/windows-pwd.test.ts --rerun-each 10 passed all 20 tests (10 per entry) from packages/cli on macOS.
bun test --timeout 30000 test/mini.test.ts test/mini-host.test.ts test/run/windows-pwd.test.ts passed all 22 tests.
bun run typecheck:tsc passed from packages/cli after the required workspace sources and dependencies were hydrated. Root bun run check remains incomplete locally because root lint tooling is unavailable. Native Windows execution of the migrated regression remains pending; the released v2.2.5 Windows reproduction above is separate evidence.
Background
Found while integrating OpenCode into skill-up, an open-source CLI for evaluating Agent Skills. The standalone reproduction above uses OpenCode directly.
Visual
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 72" width="240" height="72" fill="none">
<rect x="8" y="22" width="75" height="28" rx="6" stroke="currentColor" opacity=".35"/>
<text x="45" y="40" text-anchor="middle" fill="currentColor" font-family="monospace" font-size="12">/c/work</text>
<path d="M91 36h35m-5-5 5 5-5 5" stroke="currentColor" opacity=".5"/>
<circle cx="95" cy="36" r="3" fill="currentColor" opacity=".7">
<animate attributeName="cx" values="95;120;95" dur="2.4s" repeatCount="indefinite"/>
<animate attributeName="opacity" values=".3;.9;.3" dur="2.4s" repeatCount="indefinite"/>
</circle>
<rect x="134" y="22" width="98" height="28" rx="6" stroke="currentColor" opacity=".65"/>
<text x="174" y="40" text-anchor="middle" fill="currentColor" font-family="monospace" font-size="12">C:/work</text>
<path d="m212 36 4 4 7-8" stroke="currentColor" stroke-width="1.5"/>
</svg>
Checklist
- Kept the change focused on the reported Windows PWD regression.
- Added a regression against the real command boundary.
- Run the regression on Windows and complete package tests/type checks.
Added by the opencode bot (AI-generated).
Related: #56386
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks correct and low-risk. Passing PWD through the existing FSUtil.windowsPath() turns Git Bash paths like /c/... into C:/... on win32 and changes nothing on other platforms, so POSIX runs keep using PWD as before.
I couldn't reproduce the original failure because it needs native Windows with Git Bash, and this sandbox runs Linux. I checked the conversion directly by faking process.platform = "win32": /c/Users/a b/work, /c and /cygdrive/d/x all map to the right drive paths, and native paths are left alone. bun test test/run (17/17) and tsc -b pass.
Public API: unchanged.
Notes:
- Open #56389 changes this same line to
process.cwd() for a stale-PWD bug. That would also fix this one, so the two conflict and maintainers will need to choose between normalizing PWD and dropping it.
- The new subprocess test passes on Linux and macOS with or without the fix, because the conversion does nothing there. It only guards the fix on the Windows CI job. For a one-line fix it is fairly heavy, and it depends on the malformed
http://[ endpoint failing before any network access. It can be dropped to keep the change minimal, or kept if maintainers want Windows coverage.
Related: #56386
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
zpzjzj
changed the title
fix(cli): normalize Windows PWD in v1 run bridge
fix(cli): normalize Windows PWD in run command
Nov 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new commit applies the same fix to the rewritten run.ts, which is the path opencode run uses now. The change looks correct. I couldn't run it on Windows. bun test test/run (27/27) and tsc -b pass on Linux.
Public API: unchanged.
One gap: localDirectory() in packages/cli/src/mini.ts still does process.chdir(process.env.PWD ?? process.cwd()) without converting the path. So opencode mini started from Git Bash will probably still fail with the same Failed to change directory to /c/... error. Applying the same FSUtil.windowsPath() call there would cover it.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks for catching the mini entry. Addressed in 3fa61e0: mini.localDirectory() now uses the same FSUtil.windowsPath() conversion as run, preserving POSIX behavior.
The subprocess regression now covers both real entry points and verifies the selected directory canonically. The mini child simulates only stdin/stdout TTY flags and exits on invalid model syntax after directory selection, before rendering the frontend or making any server/model requests; it does not override the platform or export a test-only production helper.
With pinned Bun 1.4.4 on macOS, both entries passed 10 repetitions (20/20), the focused mini/mini-host/PWD suite passed 22/22, and bun run typecheck:tsc passed from packages/cli. Native Windows execution of these regressions remains pending.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the gap from my last review: mini.ts now converts Git Bash paths in localDirectory() the same way as run.ts, so opencode mini from Git Bash should get past the directory check too. In runMini the directory is chosen before the invalid --model is rejected, so the mini test case does reach the step being fixed. test/run/windows-pwd.test.ts and test/mini.test.ts pass (15/15) and tsc -b passes. I couldn't run it on native Windows.
Public API: unchanged.
Adding the mini case makes the regression test harder to follow: it builds a child script from a string with a branch for each command and fakes the TTY flags. It also still passes with or without the fix outside Windows.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|