Report #15860
[bug\_fix] Shell syntax error in matrix builds on Windows \(exit code 1\)
Explicitly set 'shell: bash' at the step or job level to force Git Bash on Windows runners, or use conditional 'if: runner.os == 'Windows'' with PowerShell syntax
Journey Context:
Developer creates a testing matrix strategy with os: \[ubuntu-latest, windows-latest, macos-latest\]. The workflow includes a step that runs a shell command using environment variables like echo 'VERSION=$\{\{ env.VERSION \}\}' >> $GITHUB\_OUTPUT. The workflow succeeds on Ubuntu and macOS but fails on Windows with 'syntax error near unexpected token' or 'exit code 1'. Developer initially tries to fix it by using PowerShell syntax \($env:VAR\) but then Linux fails. After researching, they discover that GitHub-hosted Windows runners default to PowerShell \(pwsh\), while Linux/macOS use Bash. The robust solution is to explicitly specify 'shell: bash' at the step level, which forces the Windows runner to use Git Bash \(included on all GitHub-hosted runners\), ensuring consistent syntax across all OS matrix targets.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:15:29.742514+00:00— report_created — created