Skip to content

Windows: bash tool in OpenPI derived sessions (subagent / Web) incorrectly invokes WSL stub; shellPath setting is ignored #419

Description

@zhujiangbo

Description

On Windows systems without WSL installed, the bash tool in OpenPI-created subagent / Web sessions fails with the same error (exit code 1) for any command, even something as simple as echo hi:

??? Linux ? Windows ?????????????
?????? Microsoft Store ??????:
https://aka.ms/wslstore

(The message above is in Chinese and originates from C:\Windows\System32\bash.exe, the WSL launcher stub, not a real bash shell.)

This indicates the tool is invoking the WSL stub (System32\bash.exe) rather than the user-configured shell (e.g., Git Bash).


Environment

  • OS: Windows (Chinese edition), WSL not installed
  • Git for Windows: installed at D:\Git (non‑default path)
  • Pi version: 0.85.1
  • OpenPI version: 0.5.0
  • Global setting: ~/.pi/agent/settings.json contains "shellPath": "D:/Git/bin/bash.exe" (the file exists and is executable)

Steps to Reproduce

  1. Configure "shellPath": "D:/Git/bin/bash.exe" in settings.json.
  2. In the interactive Pi session, run !echo hiworks as expected (hi is printed), confirming the main flow respects shellPath.
  3. Enter an OpenPI subagent or Web session and use the bash tool to execute any command (e.g., echo hi) → the above WSL stub error appears.

Root Cause (Hypothesis)

  • The main interactive flow follows the Pi documentation and respects settings.shellPath.
  • However, the bash tool in OpenPI‑derived sessions hard‑codes a bare bash call and does not propagate the user‑configured shellPath.
  • On Windows, CreateProcess searches System32 before PATH, so it finds System32\bash.exe—the WSL stub—first. Changing PATH alone cannot override this because the system directory takes precedence.
  • Code‑level confirmation needed: The host registration for the bash tool in subagent / Web sessions should be checked to see whether it reads shellPath.

Suggested Fixes

  1. Align the bash tool in derived sessions with the main flow’s shell resolution logic:
    shellPath → Git Bash discovery → fallback to bash—but never use the System32 stub.
  2. If resolution results in System32\bash.exe (the WSL stub), pre‑check whether WSL is actually available. If not, fail fast with a clear, actionable error message.
  3. On Windows, affected sessions could fall back to or switch to a powershell tool as an alternative.
  4. Minor: Ensure tool output is decoded correctly (e.g., GBK for legacy console code pages) to avoid garbled messages that obscure the real error.

Workaround

  • Perform shell operations inside the main interactive Pi session where shellPath is respected.
  • After modifying the configuration, restart the host process that serves OpenPI sessions.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    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