Bash tool executes bash commands with cmd.exe #3035

Closed
opened 2026-02-16 17:38:19 -05:00 by yindo · 3 comments
Owner

Originally created by @keathmilligan on GitHub (Nov 21, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

The bash tool frequently tries to run commands like mkdir -p ... using spawn, which on Window, defaults to using cmd.exe as the shell. This results in a directory called -p being created and subsequent commands failing.

OpenCode version

1.0.85

Steps to reproduce

  1. Run opencode on Windows.
  2. Issue a prompt like create the path "src/test".

Screenshot and/or share link

# Create src/test directory path
$ mkdir -p src/test
The syntax of the command is incorrect.

list the directory and note that a -p directory has been created.

Operating System

Windows 11

Terminal

Windows Terminal

Originally created by @keathmilligan on GitHub (Nov 21, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description The bash tool frequently tries to run commands like `mkdir -p ...` using `spawn`, which on Window, defaults to using `cmd.exe` as the shell. This results in a directory called `-p` being created and subsequent commands failing. ### OpenCode version 1.0.85 ### Steps to reproduce 1. Run opencode on Windows. 2. Issue a prompt like `create the path "src/test"`. ### Screenshot and/or share link ``` # Create src/test directory path $ mkdir -p src/test The syntax of the command is incorrect. ``` list the directory and note that a `-p` directory has been created. ### Operating System Windows 11 ### Terminal Windows Terminal
yindo added the bug label 2026-02-16 17:38:19 -05:00
yindo closed this issue 2026-02-16 17:38:19 -05:00
Author
Owner

@rekram1-node commented on GitHub (Nov 21, 2025):

ill fix

@rekram1-node commented on GitHub (Nov 21, 2025): ill fix
Author
Owner

@keathmilligan commented on GitHub (Nov 21, 2025):

Local hack I'm currently using:

packages/opencode/src/tool/bash.ts:148

const shell = process.platform === "win32" && process.env.SHELL?.includes("bash") ? process.env.SHELL : true
    const proc = spawn(params.command, {
      shell,
      ...
@keathmilligan commented on GitHub (Nov 21, 2025): Local hack I'm currently using: packages/opencode/src/tool/bash.ts:148 ``` const shell = process.platform === "win32" && process.env.SHELL?.includes("bash") ? process.env.SHELL : true const proc = spawn(params.command, { shell, ... ```
Author
Owner

@rekram1-node commented on GitHub (Nov 21, 2025):

should be fixed on latest

@rekram1-node commented on GitHub (Nov 21, 2025): should be fixed on latest
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3035