Skip to content

[Windows] Invalid inherited PATHEXT can break native child commands inside local agent sessions #6934

Description

@github-lover-9999

Summary

On a packaged Windows installation, I traced repeated native-command failures inside a local-agent session to the environment passed from the daemon into the agent process.

The affected runtime environment contained:

PATHEXT=.CPL

instead of a normal Windows executable-extension list.

That value propagated into the agent and its nested shell/tool processes.

Under the affected environment, otherwise-normal native commands intermittently lost stdout/stderr or failed with the Windows status:

2147942632
0x800700e8
ERROR_NO_DATA

Normalizing PATHEXT before spawning the agent eliminated the failures in controlled tests.

The issue was reproduced and locally fixed on packaged 0.17.0.

I also checked 0.19.0; this specific agent-runtime PATHEXT normalization is still not present there.

Environment

  • Windows 11
  • packaged desktop build
  • reproduced on 0.17.0
  • checked against 0.19.0
  • local CLI agent runtime
  • failure occurs in child/nested native-command execution

No user-specific paths are required to reproduce the condition.

Root-cause evidence

The environment inherited by the daemon/agent contained:

PATHEXT=.CPL

The problematic value was preserved into nested agent commands.

A controlled runtime patch normalized PATHEXT on Windows only when the inherited value did not contain .EXE.

Conceptually:

if (process.platform === "win32") {
  const key =
    Object.keys(env).find(
      (name) => name.toLowerCase() === "pathext",
    ) ?? "PATHEXT";

  const current =
    typeof env[key] === "string"
      ? env[key]
      : "";

  if (!/\.exe/i.test(current)) {
    env[key] =
      ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC";
  }
}

This is included to describe the verified mitigation, not to prescribe the exact implementation.

Verification after normalization

The patched runtime passed:

  • cmd echo ×3
  • node --version ×3
  • python --version ×3
  • additional Node/Python one-shot commands
  • failure → next-command recovery
  • real cancellation / SIGTERM
  • command after cancellation
  • long no-output command followed by recovery
  • 20 sequential command executions
  • additional read-only smoke runs

The previous 0x800700e8 / missing-output behavior did not recur.

Expected behavior

Local-agent sessions launched from the packaged Windows application should receive a usable Windows executable environment even if the desktop launcher inherited a damaged or unusually narrow PATHEXT.

At minimum, .EXE should remain resolvable for nested native commands.

Related work

There is a related open PR, #6049, which improves Windows .cmd / .bat executable resolution when PATHEXT is stripped or narrowed.

This report is slightly different:

#6049:
host-side executable resolution

this issue:
the PATHEXT value propagated into the spawned agent runtime
and then into nested shell/native commands

The two fixes may be complementary.

Suggested regression test

Add a Windows runtime-env test equivalent to:

const env = createAgentRuntimeEnv(
  {
    PATH: "...",
    PATHEXT: ".CPL",
  },
  daemonUrl,
  token,
  nodeBin,
);

expect(
  Object.entries(env)
    .find(([key]) => key.toLowerCase() === "pathext")
    ?.[1],
).toMatch(/\.EXE/i);

The exact normalization policy is up to the maintainers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions