Skip to content

Windows native: shell env fallback failed with spawnSync /bin/sh ENOENT #84795

Closed

Description

@JIRBOY

Describe the bug
When running OpenClaw 2026.5.19 on native Windows (not WSL2), the following warning appears during startup:

[openclaw] shell env fallback failed: spawnSync /bin/sh ENOENT

To Reproduce
Steps to reproduce the behavior:

  1. Install OpenClaw 2026.5.19 on native Windows
  2. Run openclaw or openclaw status
  3. See the warning about /bin/sh ENOENT

Expected behavior
OpenClaw should detect Windows platform and skip the shell env fallback that relies on /bin/sh, which doesn't exist on Windows.

Environment:

  • OS: Windows 10/11 (native, not WSL2)
  • OpenClaw version: 2026.5.19

Root Cause
In src/infra/shell-env.ts, the probeLoginShellEnv function attempts to execute /bin/sh to probe the login shell environment. On Windows, this shell doesn't exist, causing the ENOENT error.

While getShellPathFromLoginShell already has a Windows platform check, probeLoginShellEnv (called by loadShellEnvFallback) does not have this check.

Proposed Fix
Add a Windows platform check at the beginning of probeLoginShellEnv function:

function probeLoginShellEnv(params: {
  env: NodeJS.ProcessEnv;
  timeoutMs?: number;
  exec?: typeof execFileSync;
  platform?: NodeJS.Platform;
}): LoginShellEnvProbeResult {
  const platform = params.platform ?? process.platform;
  if (platform === "win32") {
    return { ok: true, shellEnv: new Map() };
  }
  // ... rest of the function
}

Additional context
Related to the Windows native support improvements mentioned in the 5.19 release notes.

Activity

  1. clawsweeper commented on May 21, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.

    Workflow note: Future ClawSweeper reviews update this same comment in place.

    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

    Summary
    This is a valid, narrow Windows startup bug on current main: the shell-env fallback still reaches the /bin/sh probe path, and only the separate PATH helper has a Windows skip.

    Reproducibility: yes. source inspection gives a high-confidence reproduction path: enable shell-env import on native Windows with a missing expected key, and current main reaches the /bin/sh exec path. I did not run native Windows here, so this is source-reproducible rather than live reproduced.

    Next step
    This is a narrow source-proven repair in the shell-env fallback with obvious unit coverage and a bounded Windows smoke path.

    Review details

    Best possible solution:

    Add a testable win32 no-op for shell-env import in the fallback/probe path, preserve existing POSIX behavior, and add focused regression coverage plus a changelog entry if this ships as a user-visible fix.

    Do we have a high-confidence way to reproduce the issue?

    Yes, source inspection gives a high-confidence reproduction path: enable shell-env import on native Windows with a missing expected key, and current main reaches the /bin/sh exec path. I did not run native Windows here, so this is source-reproducible rather than live reproduced.

    Is this the best way to solve the issue?

    Yes, the proposed direction is the narrow maintainable fix if implemented as a platform-aware skip in the fallback/probe path with regression coverage. It should not grow into an implicit PowerShell environment importer without a separate product decision.

    Label changes:

    • add P2: The report is a valid startup/config bug with limited blast radius and a clear narrow fix path.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
    • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

    Label justifications:

    • P2: The report is a valid startup/config bug with limited blast radius and a clear narrow fix path.

    Acceptance criteria:

    • node scripts/run-vitest.mjs src/infra/shell-env.test.ts
    • Native Windows or Testbox smoke: run OPENCLAW_LOAD_SHELL_ENV=1 openclaw status with a missing expected key and verify no /bin/sh warning is emitted.

    What I checked:

    • reported behavior: The provided issue body reports OpenClaw 2026.5.19 on native Windows warning [openclaw] shell env fallback failed: spawnSync /bin/sh ENOENT during openclaw or openclaw status, and proposes skipping the fallback on win32.
    • current fallback path: loadShellEnvFallback calls probeLoginShellEnv whenever expected keys are missing, and probeLoginShellEnv resolves a shell and invokes the login-shell exec path without any platform check. (src/infra/shell-env.ts:171, a30ac3f8d7cb)
    • existing Windows skip is not on the failing path: getShellPathFromLoginShell already returns null on platform === "win32", but that platform option is not threaded through loadShellEnvFallback or probeLoginShellEnv. (src/infra/shell-env.ts:282, a30ac3f8d7cb)
    • test gap: The current shell-env tests cover the win32 skip only for getShellPathFromLoginShell; the fallback tests still assert /bin/sh fallback behavior and do not cover loadShellEnvFallback on win32. (src/infra/shell-env.test.ts:405, a30ac3f8d7cb)
    • documented contract: Docs describe env.shellEnv and OPENCLAW_LOAD_SHELL_ENV=1 as optional login-shell import for missing expected keys, so skipping POSIX shell probing on native Windows preserves the documented import boundary better than warning on /bin/sh. Public docs: docs/gateway/configuration.md. (docs/gateway/configuration.md:653, a30ac3f8d7cb)
    • release behavior: The v2026.5.19 tag points at a185ca2, and git show v2026.5.19:src/infra/shell-env.ts shows the same no-platform-guard probe/fallback path as current main. (src/infra/shell-env.ts:171, a185ca283a74)

    Likely related people:

    • steipete: Blame and git log show Peter Steinberger introduced the current shell-env probe/fallback implementation in d147036. (role: introduced behavior; confidence: high; commits: d1470360c420; files: src/infra/shell-env.ts, src/infra/shell-env.test.ts, src/config/io.ts)
    • romneyda: Recent history shows Dallin Romney touched src/config/io.ts, which calls loadShellEnvFallback, while not appearing to own the shell-env probe itself. (role: recent adjacent contributor; confidence: low; commits: d91ef6bb171d; files: src/config/io.ts)

    Remaining risk / open question:

    • I did not run a live native Windows repro in this read-only review; the source path is clear, but the final patch should still get a Windows or Testbox smoke before the issue is closed.

    Codex review notes: model gpt-5.5, reasoning high; reviewed against a30ac3f8d7cb.

  2. added
    P2Normal backlog priority with limited blast radius.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    on May 21, 2026
  3. JIRBOY commented on May 24, 2026

    @JIRBOY
    ContributorAuthor

    Additional reproduction confirmation on OpenClaw 2026.5.22 (a374c3a) / Windows 10 19045 / Node 24.14.1.

    This bug continues to affect multiple commands beyond startup:

    Affected commands confirmed:

    • openclaw doctor - shows the ENOENT error before and after output
    • openclaw completion --write-state - FAILS entirely, shell completion cache cannot be generated
    • openclaw status --all - shows the error

    The probeLoginShellEnv function is likely called via loadShellEnvFallback during CLI initialization, affecting any command path that needs shell environment variables. On Windows, getShellPathFromLoginShell already skips the probe (has win32 check), but probeLoginShellEnv does not, causing the ENOENT.

    This is a P2 that blocks shell completion generation on Windows native installs.

  4. JIRBOY commented on May 24, 2026

    @JIRBOY
    ContributorAuthor

    Additional reproduction confirmation on OpenClaw 2026.5.22 (a374c3a) / Windows 10 19045 / Node 24.14.1.

    This bug continues to affect multiple commands beyond startup:

    Affected commands confirmed:

    • ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
      ██░▄▄▄░██░▄▄░██░▄▄▄██░▀██░██░▄▄▀██░████░▄▄▀██░███░██
      ██░███░██░▀▀░██░▄▄▄██░█░█░██░█████░████░▀▀░██░█░█░██
      ██░▀▀▀░██░█████░▀▀▀██░██▄░██░▀▀▄██░▀▀░█░██░██▄▀▄▀▄██
      ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
      OPENCLAW

    ┌ OpenClaw doctor
    │
    ◇ Security ─────────────────────────────────────────────────────────────╮
    │ │
    │ - WARNING: openclaw.json contains plaintext secret-bearing config │
    │ fields. │
    │ Paths: gateway.auth.token, models.providers.kimi-coding.apiKey, │
    │ plugins.entries.moonshot.config.webSearch.apiKey, │
    │ channels.feishu.appSecret │
    │ Agents or workspace tools that can read config files may see these │
    │ API keys/tokens. │
    │ Migrate them to SecretRefs with openclaw secrets configure or │
    │ openclaw secrets apply, then verify with openclaw secrets audit │
    │ --check. │
    │ - Run: openclaw security audit --deep │
    │ │
    ├────────────────────────────────────────────────────────────────────────╯
    │
    ◇ Skills status ───────────╮
    │ │
    │ Eligible: 223 │
    │ Missing requirements: 0 │
    │ Blocked by allowlist: 0 │
    │ │
    ├───────────────────────────╯
    │
    ◇ Plugins ──────╮
    │ │
    │ Loaded: 8 │
    │ Imported: 0 │
    │ Disabled: 86 │
    │ Errors: 0 │
    │ │
    ├────────────────╯
    Run "openclaw doctor --fix" to apply changes.
    │
    └ Doctor complete. — shows before and after doctor output

    • — fails entirely with the same error, shell completion cache cannot be generated
    • OpenClaw status --all

    Overview
    ┌────────────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Item │ Value │
    ├────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
    │ Version │ 2026.5.22 │
    │ OS │ windows 10.0.19045 (x64) │
    │ Node │ 24.14.1 │
    │ Config │ $OPENCLAW_HOME.openclaw\openclaw.json │
    │ Dashboard │ http://127.0.0.1:18789/ │
    │ Tailscale exposure │ off │
    │ Channel │ stable (default) │
    │ Update │ pnpm · up to date · npm latest 2026.5.22 │
    │ Gateway │ local · ws://127.0.0.1:18789 (local loopback) · reachable 189ms · auth token · HostJi (10.197. │
    │ │ 73.12) app 2026.5.22 windows 10.0.19045 │
    │ Security │ Run: openclaw security audit --deep │
    │ Gateway self │ unknown │
    │ Gateway service │ Scheduled Task not installed │
    │ Node service │ Scheduled Task not installed │
    │ Agents │ 1 total · 0 bootstrapping · 1 active · 5 sessions │
    │ Secrets │ none │
    └────────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────┘

    Channels
    ┌──────────┬─────────┬────────┬────────────────────────────────────────────────────────────────────────────────────────┐
    │ Channel │ Enabled │ State │ Detail │
    ├──────────┼─────────┼────────┼────────────────────────────────────────────────────────────────────────────────────────┤
    │ Feishu │ ON │ OK │ configured │
    └──────────┴─────────┴────────┴────────────────────────────────────────────────────────────────────────────────────────┘

    Feishu accounts
    ┌──────────┬──────────┬────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Account │ Status │ Notes │
    ├──────────┼──────────┼────────────────────────────────────────────────────────────────────────────────────────────────┤
    │ default │ OK │ credential available in gateway runtime │
    └──────────┴──────────┴────────────────────────────────────────────────────────────────────────────────────────────────┘

    Agents
    ┌────────────┬────────────────┬──────────┬──────────┬──────────────────────────────────────────────────────────────────┐
    │ Agent │ Bootstrap file │ Sessions │ Active │ Store │
    ├────────────┼────────────────┼──────────┼──────────┼──────────────────────────────────────────────────────────────────┤
    │ main │ ABSENT │ 5 │ just now │ $OPENCLAW_HOME.openclaw\agents\main\sessions\sessions.json │
    └────────────┴────────────────┴──────────┴──────────┴──────────────────────────────────────────────────────────────────┘

    Diagnosis (read-only)

    Gateway connection details:
    Gateway target: ws://127.0.0.1:18789
    Source: local loopback
    Config: D:\Personal\Settings.openclaw\openclaw.json
    Bind: loopback

    ✓ Config: D:\Personal\Settings.openclaw\openclaw.json
    ✓ Secret diagnostics (0)
    ✓ Restart sentinel: none
    ✓ Port 18789
    Detected OpenClaw Gateway listener on the configured port.
    ! Tailscale exposure: off · daemon unknown
    ✓ Skills: 223 eligible · 0 missing · D:\Personal\OpenClaw
    ✓ Plugin compatibility (none)
    ✓ Agent activity: 1 active in 30m · 5 sessions
    ✓ Inbound delivery telemetry: received 3 · dispatch 3/3 · turns 4 · processed 3
    latest delivery event: 7m ago

    Gateway restart attempts (tail): C:\Users\Super Manager.openclaw\logs\gateway-restart.log
    [���� 2026/05/16 16:35:06.12] openclaw restart log initialized
    [���� 2026/05/16 16:35:06.12] openclaw restart attempt source=update target=OpenClaw Gateway
    ✓ Channel issues (none)

    Pasteable debug report. Auth tokens redacted.
    Troubleshooting: https://docs.openclaw.ai/troubleshooting — shows the error

    Additional context:
    The function () is likely called via during CLI initialization, affecting any command path that needs shell environment variables. On Windows, already skips the probe (has check), but does not, causing the ENOENT.

    This is a P2 that blocks shell completion generation on Windows native installs.

  5. locked as resolved and limited conversation to collaborators on May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions