-
-
Notifications
You must be signed in to change notification settings - Fork 69.6k
env.vars.PATH not working on Windows + PATH bootstrap only adds Unix paths #19910
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
staleMarked as stale due to inactivityMarked as stale due to inactivity
Description
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
- Set
env.vars.PATHin openclaw.json with a custom path (e.g.,C:\Program Files\GitHub CLI) - Set
env.vars.GH_TOKEN - Restart Gateway
- Run:
gh auth status
Expected Behavior
env.vars.PATHshould be prepended to the exec shell PATH- gh command should be found via the custom PATH
Actual Behavior
env.vars.GH_TOKENworks correctly (injected as environment variable)env.vars.PATHis 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>
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
staleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Give feedbackNo fields configured for issues without a type.