Desktop app always uses SHELL (WSL) on Windows
Description
Desktop app ignores OPENCODE_GIT_BASH_PATH.
when execution with BashTool, always uses SHELL (WSL) on Windows
Environment:
- OS: Windows 10
- OpenCode: Desktop version
- Git Bash: Installed at
C:\Program Files\Git\bin\bash.exe - WSL: Ubuntu installed
-
OPENCODE_GIT_BASH_PATHset toC:\Program Files\Git\bin\bash.exein Windows environment variables
$ where bash
C:\Program Files\Git\usr\bin\bash.exe
C:\Windows\System32\bash.exe
Description:
The desktop app ignores the OPENCODE_GIT_BASH_PATH environment variable when spawning the CLI sidecar. The CLI shell detection logic in shell.ts prioritizes process.env.SHELL over OPENCODE_GIT_BASH_PATH, causing it to use WSL bash instead of Git Bash. This breaks the Bash tool since Windows environment variables (PATH, PYTHONPATH, etc.) are not inherited by the WSL environment.
Reproduction:
- Install OpenCode Desktop on Windows
- Install Git Bash and WSL
- Set
OPENCODE_GIT_BASH_PATH=C:\Program Files\Git\bin\bash.exein Windows environment variables
Expected Behavior:
The Bash tool should use Git Bash as configured via OPENCODE_GIT_BASH_PATH, preserving all Windows environment variables.
Actual Behavior:
The Bash tool uses WSL bash (from SHELL environment variable), causing:
- All Windows environment variables to be unavailable
- Commands requiring Windows tools to fail
- Configurations in Git Bash (PATH, npm, Python, etc.) to be ignored
Root Cause:
In packages/desktop/src-tauri/src/cli.rs, the create_command() function for Windows does not pass the OPENCODE_GIT_BASH_PATH environment variable to the CLI sidecar:
#[cfg(target_os = "windows")]
pub fn create_command(app: &tauri::AppHandle, args: &str) -> Command {
// ... existing env variables ...
.env("OPENCODE_CLIENT", "desktop")
.env("XDG_STATE_HOME", &state_dir);
// Missing: .env("OPENCODE_GIT_BASH_PATH", ...)
}
The CLI's shell detection in packages/opencode/src/shell/shell.ts prioritizes SHELL:
export const acceptable = lazy(() => {
const s = process.env.SHELL // Checked first
if (s && !BLACKLIST.has(...)) return s
return fallback() // OPENCODE_GIT_BASH_PATH is only checked here
})
Plugins
No response
OpenCode version
1.1.19
Steps to reproduce
1.Git-Bash Installed. 2.WSL Installed.
Screenshot and/or share link
No response
Operating System
Win10 22H2
Terminal
OpenCode-Desktop-Win64
This issue might be a duplicate of existing issues. Please check:
- #8378: 2 bugs spotted when running Windows Desktop connects to opencode server in WSL: Shell runtime & Path Detection - specifically addresses shell detection logic issues with
process.env.SHELLnot being properly handled in WSL/Windows environments
Feel free to ignore if this doesn't address your specific case.
You need to get your PATH order right in order for this to work.
WSL bash lives in C:/Windows/System32
if you want git bash to be executed, this needs to have higher priority:
on top you can also set both env variables SHELL and OPENCODE_GIT_BASH_PATH to be on the safe side: