Skip to content

fix: createOpencode function failure on Windows due to spawn usage#18789

Open
webuilder wants to merge 3 commits intoanomalyco:devfrom
webuilder:dev
Open

fix: createOpencode function failure on Windows due to spawn usage#18789
webuilder wants to merge 3 commits intoanomalyco:devfrom
webuilder:dev

Conversation

@webuilder
Copy link

@webuilder webuilder commented Mar 23, 2026

Adds { shell: process.platform === 'win32' } when spawning child processes on Windows, allowing the system to resolve opencode.cmd from the PATH.

Issue for this PR

Closes #18792

Type of change

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

What does this PR do?

When I use opencode sdk on windows. I called createOpencode function, then got a fail

node:internal/child_process:286
      const err = new ErrnoException(exitCode, syscall);
                  ^

Error: spawn opencode ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:89:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn opencode',
  path: 'opencode',
  spawnargs: [ 'serve', '--hostname=127.0.0.1', '--port=0' ]
}

So I changed server.ts, I added a shell flag to the spawn function arguments, setting it to true for Windows and false otherwise.

How did you verify your code works?

Verified the fix on Windows 11 and Ubuntu.

Screenshots / recordings

No ui changed.

Checklist

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

If you do not follow this template your PR will be automatically rejected.

Adds { shell: process.platform === 'win32' } when spawning child processes on Windows,
allowing the system to resolve opencode.cmd from the PATH.
@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. needs:title labels Mar 23, 2026
@github-actions
Copy link
Contributor

Hey! Your PR title Fix createOpencode function failure on Windows due to spawn usage doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 23, 2026
@github-actions
Copy link
Contributor

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

@webuilder webuilder changed the title Fix createOpencode function failure on Windows due to spawn usage fix: createOpencode function failure on Windows due to spawn usage Mar 23, 2026
@rekram1-node rekram1-node requested a review from Hona March 23, 2026 18:41
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.

createOpencode function failure on Windows due to spawn usage

1 participant