Windows: tools.exec cannot find docker, rg, or gh even though they work in PowerShell
Fix native Windows cases where the Scheduled Task gateway uses a different PATH than your interactive shell, so tools.exec cannot resolve installed CLI tools.
Symptoms
- In PowerShell,
where docker,where rg, orwhere ghsucceeds. - But inside OpenClaw
tools.exec, those commands behave like they are missing. - Plugin runtime setup may fail with follow-on errors like:
npm is required to install plugin-local ... but was not found on PATH
- The problem appears only when the gateway runs as a Windows Scheduled Task.
Cause
On native Windows, the gateway service does not necessarily see the same PATH as your interactive shell.
The built-in daemon path launches through a generated wrapper such as:
%USERPROFILE%\.openclaw\gateway.cmd
So you can end up debugging a service-environment PATH mismatch, not a missing installation of docker, rg, gh, or npm.
Fix
1) Reinstall the gateway from the same shell where the commands already work
In the exact shell where these succeed:
where docker
where rg
where gh
reinstall the gateway:
openclaw gateway stop
openclaw gateway uninstall
openclaw gateway install --force --runtime node --port 18789
2) Inspect gateway.cmd, but do not treat it as durable configuration
Open:
%USERPROFILE%\.openclaw\gateway.cmd
Use it to confirm what PATH and command the Scheduled Task will actually run.
Important: this file is useful for diagnosis, but updates and reinstalls can regenerate it. Do not rely on hand-edited lines there as your long-term fix.
3) If exec really runs on the gateway, use tools.exec.pathPrepend carefully
For gateway-host exec, this can be the right fix:
{
tools: {
exec: {
pathPrepend: [
"C:\\Program Files\\Docker\\Docker\\resources\\bin",
"C:\\Users\\<you>\\AppData\\Local\\Microsoft\\WinGet\\Links"
]
}
}
}
Then restart the gateway:
openclaw gateway restart
4) If enabling pathPrepend makes PATH worse, remove it immediately
Some Windows issue reports have shown tools.exec.pathPrepend behaving badly enough to effectively break PATH resolution.
If even powershell or where.exe disappears inside exec after enabling it:
- remove
tools.exec.pathPrependfrom config, - restart the gateway,
- fall back to full executable paths,
- or run the gateway in the foreground while debugging.
5) Use foreground gateway as the clean control test
openclaw gateway run --port 18789
If the commands work in foreground mode but fail under Scheduled Task, you have confirmed this is a Windows service-environment problem.
Verify
- In the same PowerShell used for install,
where docker,where rg, orwhere ghsucceeds. tools.execcan run the same command in a fresh session.- If you used foreground
gateway run, the command also works there.