Skip to content

fix(shell): avoid non-string stdout parsing in cygpath path resolution#29384

Closed
SpencerJung wants to merge 1 commit into
anomalyco:devfrom
SpencerJung:fix/26932-bash-split
Closed

fix(shell): avoid non-string stdout parsing in cygpath path resolution#29384
SpencerJung wants to merge 1 commit into
anomalyco:devfrom
SpencerJung:fix/26932-bash-split

Conversation

@SpencerJung
Copy link
Copy Markdown

Issue for this PR

Closes #26932

What does this PR do?

This replaces the spawner.lines(...) call inside packages/opencode/src/tool/shell.ts's Windows cygpath() helper with an explicit spawn() + stdout decode flow.

That keeps stdout as a guaranteed string before calling .split(), and only parses the first line when the subprocess exits successfully. If the helper fails, behavior stays the same and path resolution falls back cleanly.

Why this fixes the issue

The reported crash happens before the shell subprocess actually runs because the output handling path assumes stdout is already a string. By collecting and decoding handle.stdout ourselves, this code no longer depends on that brittle path and avoids the (result.stdout ?? "").split is not a function failure.

Verification

  • lsp_diagnostics on packages/opencode/src/tool/shell.ts: no diagnostics
  • bun test test/tool/shell.test.ts in packages/opencode: failed due missing dependency module @babel/helper-validator-identifier after install problems
  • bun x tsc -p tsconfig.json --noEmit in packages/opencode: failed due existing/missing dependency type resolution errors (for example solid-js, drizzle-orm, zod)
  • bun install at repo root: failed because tree-sitter-powershell native build could not find a Visual Studio C++ toolchain on this Windows machine

Scope

  • Single-file fix only: packages/opencode/src/tool/shell.ts
  • No lockfiles modified

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential duplicate found:

Why it's related: This PR has the identical title and appears to address the same issue with cygpath stdout parsing in the Windows shell path resolution. It's likely an earlier attempt or related fix for the same problem that issue #26932 describes.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 26, 2026
@github-actions github-actions Bot closed this May 26, 2026
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.

Bash tool always returns "(result.stdout ?? "").split is not a function" - shell subprocess never executes

1 participant