Skip to content

env.vars.PATH not working on Windows + PATH bootstrap only adds Unix paths #19910

@LKCY33

Description

@LKCY33

Description

On Windows, the env.vars.PATH configuration in openclaw.json is not being applied to the exec tool shell environment. Additionally, the PATH bootstrap logic in src/infra/path-env.ts only adds Unix-specific paths, which don't exist on Windows.

Steps to Reproduce

  1. Set env.vars.PATH in openclaw.json with a custom path (e.g., C:\Program Files\GitHub CLI)
  2. Set env.vars.GH_TOKEN
  3. Restart Gateway
  4. Run: gh auth status

Expected Behavior

  • env.vars.PATH should be prepended to the exec shell PATH
  • gh command should be found via the custom PATH

Actual Behavior

  • env.vars.GH_TOKEN works correctly (injected as environment variable)
  • env.vars.PATH is NOT applied
  • The exec shell PATH only contains a minimal set of paths, missing most entries from both Machine and User PATH
  • gh command is not found

Root Cause Analysis

The PATH bootstrap logic in src/infra/path-env.ts (function candidateBinDirs) only adds Unix paths:

// src/infra/path-env.ts
function candidateBinDirs(opts: EnsureOpenClawPathOpts): { prepend: string[]; append: string[] } {
  // ...
  
  // Common global install locations (macOS first).
  if (platform === "darwin") {
    prepend.push(path.join(homeDir, "Library", "pnpm"));
  }
  if (process.env.XDG_BIN_HOME) {
    prepend.push(process.env.XDG_BIN_HOME);
  }
  prepend.push(path.join(homeDir, ".local", "bin"));
  prepend.push(path.join(homeDir, ".local", "share", "pnpm"));
  prepend.push(path.join(homeDir, ".bun", "bin"));
  prepend.push(path.join(homeDir, ".yarn", "bin"));
  prepend.push("/opt/homebrew/bin", "/usr/local/bin", "/usr/bin", "/bin");  // <-- Unix only!

  return { prepend: prepend.filter(isDirectory), append: append.filter(isDirectory) };
}

These Unix paths (/opt/homebrew/bin, /usr/local/bin, /usr/bin, /bin) don't exist on Windows, so isDirectory() filters them all out. The result is that Windows gets no additional system paths from the bootstrap logic.

Missing Windows support:

  • No handling for platform === "win32"
  • No Windows system paths (e.g., C:\WINDOWS\system32, C:\Program Files\...)
  • No User PATH merging from Windows registry

Environment

  • OS: Windows
  • OpenClaw version: 2026.2.15
  • Shell: PowerShell 5.1 (Windows PowerShell)

Workaround

Use full path to executable:

& "C:\Program Files\GitHub CLI\gh.exe" <command>

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions