Skip to content

fix(windows): use cross-spawn for shim-backed commands#18010

Merged
Hona merged 12 commits intoanomalyco:devfrom
Hona:fix/shell-passthru-on-win32
Mar 18, 2026
Merged

fix(windows): use cross-spawn for shim-backed commands#18010
Hona merged 12 commits intoanomalyco:devfrom
Hona:fix/shell-passthru-on-win32

Conversation

@Hona
Copy link
Copy Markdown
Member

@Hona Hona commented Mar 17, 2026

The pain

  • Windows shim-backed commands (.cmd / .bat) were failing across upgrade, uninstall, PR handoff, IDE install, and LSP launch.
  • shell: true papers over that, but it adds quoting and process-lifecycle problems.

The solution

  • Use cross-spawn in packages/opencode/src/util/process.ts for normal argv launches.
  • Keep shell usage explicit.
  • Route LSP launches through the shared process path and keep Process.stop(...) for Windows teardown.

Why it works

  • cross-spawn handles Windows shim resolution and quoting without forcing shell semantics.
  • Built-in and configured LSP commands now launch the same way.

Fixes

Copilot AI review requested due to automatic review settings March 17, 2026 23:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Routes Windows install detection and package-manager upgrade commands through a shell so .cmd/.bat shims resolve correctly, and improves visibility into npm-registry update checks via additional logging.

Changes:

  • Forward shell through Process.run() so Process.text()/Process.run() behave consistently when shell execution is required.
  • On Windows, run install-method detection and upgrade commands with shell: true for npm/pnpm/bun/choco/scoop.
  • Add info/error logging around npm-registry “latest version” lookups (including request URL and failure details).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/opencode/src/util/process.ts Passes opts.shell from Process.run() down to spawn() so callers can reliably enable shell execution.
packages/opencode/src/installation/index.ts Enables shell routing on Windows for detection/upgrades and adds registry lookup logging for update checks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Hona Hona changed the title fix(cli): route Windows upgrade commands through shell fix(windows): route shell-backed commands through shell Mar 18, 2026
@Hona Hona changed the title fix(windows): route shell-backed commands through shell fix(windows): use cross-spawn for shim-backed commands Mar 18, 2026
@Hona Hona merged commit 54ed87d into anomalyco:dev Mar 18, 2026
9 checks passed
AvatarGanymede pushed a commit to AvatarGanymede/opencode-dev that referenced this pull request Mar 19, 2026
demostanis pushed a commit to demostanis/opencode that referenced this pull request Mar 19, 2026
raf1hh pushed a commit to raf1hh/opencode that referenced this pull request Mar 20, 2026
demostanis pushed a commit to demostanis/opencode that referenced this pull request Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment