Skip to content

core: shell tests fail on Windows when launched from Git Bash (ambient SHELL env) #54104

Open

Description

@dpviivqb

Description

packages/core shell tests branch command syntax on process.platform === "win32" and hard-code PowerShell (e.g. test/tool-shell.test.ts), but shell selection (src/shell/select.ts, environment()) prefers process.env.SHELL whenever it is set. Git Bash exports SHELL=/usr/bin/bash, so running the core suite from Git Bash makes the shell tool select bash and every platform-branched command fails with bash syntax errors:

/usr/bin/bash: -c: line 1: syntax error near unexpected token `$env:OPENCODE_SESSION_ENV_TEST'

CI stays green because its bash steps do not propagate SHELL into the test process, so Windows CI silently runs PowerShell while a Git Bash developer machine runs bash. script/test.ts also forwards SHELL (its env filter only strips provider credentials), so the project runner reproduces this too.

Suggested fix: normalize SHELL in test/preload.ts on win32 so unit tests exercise the platform default shell, matching the PowerShell syntax the tests already assert. PR incoming.

Steps to reproduce

  1. On Windows, open Git Bash in a v2 checkout with dependencies installed.
  2. cd packages/core && SHELL=/usr/bin/bash bun run test test/tool-shell.test.ts
  3. ShellTool tests fail with bash syntax errors; the same command from PowerShell (where SHELL is unset) passes.

Operating System

Windows 11 (10.0.26200)

Terminal

Git Bash (MINGW64)

OpenCode version

v2 branch @ 2f3ba04

Activity

  1. opencode-agent commented on Oct 9, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report. I couldn't run this here: the failure needs Windows and Git Bash, and our sandbox is Linux, where the tests never use PowerShell syntax.

    I did read the latest v2 (2f3ba04), which is the commit you reported. The cause you describe is still there: src/shell/select.ts picks the shell from process.env.SHELL first, and test/preload.ts doesn't touch SHELL. So running the core suite from Git Bash should still pick bash while the tests assert PowerShell syntax.

    A maintainer with a Windows setup will need to confirm it. Your PR that normalizes SHELL in the test preload will be a useful starting point for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions