Windows: allow configuring the default session shell via config

Open 💬 5 comments Opened Apr 2, 2026 by LXL47
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

Summary

Codex currently defaults to PowerShell for the Windows session shell path. That makes it hard for users who primarily work in Git Bash or another already-supported shell to make that shell the default for Codex sessions.

I prepared a change that adds an explicit Windows config entry:

[windows]
shell_path = "C:\\Program Files\\Git\\bin\\bash.exe"

When windows.shell_path is configured, Codex uses that executable as the default session shell. When it is not configured, the current behavior remains unchanged and Windows still falls back to PowerShell.

Why this approach

I intentionally implemented this as an explicit config option rather than automatic shell detection:

  • Windows does not have a single reliable equivalent to Unix $SHELL
  • multiple bash.exe variants may exist on PATH (Git Bash, WSL, MSYS2, etc.)
  • explicit configuration is easier to reason about and avoids changing behavior for existing users

Implementation notes

The change currently does the following:

  • adds windows.shell_path to config parsing
  • supports profile.windows.shell_path overriding the top-level value
  • validates the configured executable against Codex's existing built-in shell detection/execution logic
  • uses the configured shell as the default session shell when no internal user_shell_override is provided
  • updates the Windows shell tool descriptions so they refer to the configured default shell rather than hardcoding PowerShell wording
  • updates docs and regenerates config.schema.json

This does not try to add arbitrary shell adapter support. The configured path must resolve to a shell executable already supported by Codex's built-in shell handling.

Testing performed

I ran:

  • cargo +stable test -p codex-tools
  • cargo +stable test -p codex-core config::tests::config_loads_windows_shell_path_from_toml -- --exact --nocapture
  • cargo +stable test -p codex-core config::tests::profile_windows_shell_path_overrides_top_level_value -- --exact --nocapture
  • cargo +stable test -p codex-core config::tests::invalid_windows_shell_path_fails_config_load -- --exact --nocapture
  • cargo +stable test -p codex-core shell::tests::configured_windows_shell_path_uses_bash -- --exact --nocapture
  • cargo +stable test -p codex-core shell::tests::invalid_windows_shell_path_is_rejected -- --exact --nocapture
  • cargo +stable test -p codex-core shell::tests::finds_powershell -- --exact --nocapture
  • cargo +stable test -p codex-core shell::tests::detects_powershell_as_default -- --exact --nocapture

Branch / commit

I could not open a PR directly because the repository currently limits PR creation to collaborators.

The proposed change is available here:

  • branch: LXL47/codex:feat/windows-shell-path-config
  • commit: 0d9010493

If this direction is acceptable, I can keep the branch available for maintainers to review or cherry-pick from.

View original on GitHub ↗

5 Comments

github-actions[bot] contributor · 4 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #15371
  • #15294

Powered by Codex Action

LXL47 · 4 months ago

A few implementation details that may help with review:

  • codex-rs/config/src/types.rs
  • adds windows.shell_path to WindowsToml
  • codex-rs/core/src/config/mod.rs
  • resolves profile.windows.shell_path before the top-level windows.shell_path
  • validates the configured path on Windows during config loading
  • surfaces a config error for unsupported / unusable executables instead of silently falling back
  • codex-rs/core/src/codex.rs
  • applies the configured shell path when constructing the default session shell
  • keeps the existing internal precedence: user_shell_override still wins if one is already provided programmatically
  • codex-rs/core/src/shell.rs
  • adds a separate helper for configured shell paths instead of reusing the model-provided-path flow
  • keeps the default behavior unchanged when no config value is present
  • codex-rs/tools/src/local_tool.rs
  • updates the Windows shell tool descriptions so they refer to the configured default shell instead of PowerShell-specific wording
  • docs/config.md and codex-rs/core/config.schema.json
  • document and expose the new config entry

A couple of scope boundaries are intentional here:

  • this does not add arbitrary shell adapter support
  • windows.shell_path must point to a shell executable already handled by Codex's built-in shell adapters
  • at the moment that means the shell types Codex already knows how to detect and execute, such as bash, sh, zsh, pwsh, powershell, and cmd
  • if windows.shell_path is unset, Windows behavior remains the same as today

I also added targeted coverage for:

  • loading windows.shell_path from config
  • profile override behavior
  • invalid configured shell paths failing config load
  • Windows shell resolution using a configured bash.exe
  • retaining the existing PowerShell default when no config is provided
caomengxuan666 · 1 month ago

Just dropping a +1 with a real consumer use case. I maintain winuxsh (https://github.com/unixwin/winuxsh), a Windows-native bash/zsh-like shell (rubash + winuxcmd, no MSYS/Cygwin/WSL layer). We have already verified that winuxsh -c "<cmd>" meets the agent non-interactive contract: no banner, clean stdout/stderr, exact exit code, native Windows paths and ~ resolution. We have users who would switch to Codex specifically if shell_command could route to winuxsh instead of PowerShell.

Everything your PR proposes is exactly what we need:

  • windows.shell_path = "..." as the single config entry point
  • profile override of the top-level value
  • validation via the existing built-in shell detection logic
  • fallback to current behavior when unset

One thing worth confirming: my winuxsh uses -c "<command>" for non-interactive mode (same as bash/zsh). Looking at codex-rs/core/src/shell.rs, derive_exec_args currently branches on ShellType and would route a custom path through the Cmd branch (/c <command>) if detect_shell_type falls back. Would the PR validation reject an unknown stem like winuxsh.exe, or is there room to add a bash/sh-compatible branch (i.e. -c rather than /c) when the configured path matches a known Unix-style shell?

Happy to help test a build or contribute test cases if it helps move this forward.

DanKaplanSES · 21 days ago

I would strongly benefit from this feature, specifically with Cygwin Bash:

[windows]
shell_path = "C:\\cygwin64\\bin\\bash.exe"

I launch Codex from Cygwin, but native Windows Codex still runs agent commands through PowerShell. I can instruct it to invoke Cygwin Bash for each command, but that is not an equivalent substitute for making Bash the actual session shell.

Claude Code supports this workflow through CLAUDE_CODE_GIT_BASH_PATH, and I use it successfully with C:\cygwin64\bin\bash.exe. Commands run directly in Cygwin, so POSIX scripts, paths, tools, skills, and permission rules behave consistently.

The PowerShell-to-Bash wrapper approach has several drawbacks:

  • It adds extra process and shell startup overhead to every short agent command.
  • It introduces a second quoting and path-translation layer, making pipes, redirects, multiline commands, heredocs, and complex arguments less reliable.
  • It makes POSIX-oriented skills and their scripts/ directories fragile, because a script may accidentally be sent directly to PowerShell.
  • It makes command approval and prefix rules less useful because PowerShell sees only a Bash-launch command, not the actual POSIX command.
  • It requires an instruction-following workaround instead of a reliable tool-level configuration.

WSL is not a drop-in replacement for every Windows-native project. Keeping a repository on C:\... while running Linux tools can cause significant cross-filesystem I/O overhead. Moving a project into WSL can also require changes to paths, toolchains, editor and debugger setup, environment variables, services, and Windows-specific build or automation dependencies.

Cygwin is the best fit for some of my existing Windows-native projects. Please consider accepting a Cygwin bash.exe path for windows.shell_path, provided it passes the existing Bash shell detection and execution checks.

PRO-2684 · 14 days ago

I'd also support this. My main reasons are:

  • Models are generally much more familiar with Bash than with PowerShell, which tends to result in more reliable shell commands.
  • PowerShell startup/execution is extremely slow on my machine, so shell-heavy agent workflows noticeably suffer.
  • Requiring WSL just to get a Bash environment feels unnecessarily heavyweight, especially when Git Bash is already readily available on many Windows development setups.

There are also a couple of closely related issues:

  • #13165 asks for choosing the shell on Windows, specifically mentioning MinGW Bash as an alternative for users who don't want WSL.
  • #16717 proposes configurable PowerShell/Git Bash support.

So I think an explicit windows.shell_path as proposed here would be a useful and fairly general solution, while preserving PowerShell as the default for existing users.