Skip to content

fix(win): prevent user PATH clobbering and normalize gateway PATH env#459

Merged
vcfgv merged 2 commits intomainfrom
bugfix/env-overriden
Mar 13, 2026
Merged

fix(win): prevent user PATH clobbering and normalize gateway PATH env#459
vcfgv merged 2 commits intomainfrom
bugfix/env-overriden

Conversation

@vcfgv
Copy link
Contributor

@vcfgv vcfgv commented Mar 13, 2026

Summary

Fixes Windows PATH corruption and gateway startup regressions reported in #269, #440, #447.

Root Causes

  • resources/cli/win32/update-user-path.ps1 could rewrite user Path unsafely and had a faulty Add-Type snippet.
  • Gateway env setup used process.env.PATH directly; on Windows real key is often Path, which could drop inherited path entries.

Changes

  • Added Windows-safe PATH helpers:
    • case-insensitive path key handling (Path/PATH)
    • deduplicate path keys before writing child env
    • prepend bundled bin safely
  • Updated gateway launch/doctor env construction to use the new helpers:
    • electron/gateway/config-sync.ts
    • electron/gateway/supervisor.ts
  • Hardened Windows PATH updater script:
    • read/write HKCU\Environment\Path with registry-kind awareness
    • refuse suspicious collapsing rewrites (anti-clobber guard)
    • fix Add-Type declaration to avoid compile errors
    • treat environment broadcast failure as warning, not fatal
  • Added unit tests for env-path behaviors:
    • tests/unit/env-path.test.ts

Verification

  • User PATH keeps existing entries after install/update.
  • Only ClawX CLI path is added (no duplicate path-key pollution).
  • openclaw --version works in new terminals.
  • Gateway starts successfully on Windows without PATH-related failures.

Related Issues

@vcfgv vcfgv force-pushed the bugfix/env-overriden branch from 77b79fe to 7078b70 Compare March 13, 2026 03:03
@vcfgv vcfgv marked this pull request as ready for review March 13, 2026 04:11
@vcfgv vcfgv merged commit 740116a into main Mar 13, 2026
3 checks passed
@vcfgv vcfgv deleted the bugfix/env-overriden branch March 13, 2026 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant