Skip to content

fix(installer): install openclaw to %APPDATA%\npm when Program Files is read-only#3

Merged
taoyizhi68 merged 1 commit into
microsofthackathons:mainfrom
taoyizhi68:fix/openclaw-install-non-elevated
May 15, 2026
Merged

fix(installer): install openclaw to %APPDATA%\npm when Program Files is read-only#3
taoyizhi68 merged 1 commit into
microsofthackathons:mainfrom
taoyizhi68:fix/openclaw-install-non-elevated

Conversation

@taoyizhi68
Copy link
Copy Markdown
Contributor

Summary

When the Node.js MSI is installed per-machine to C:\Program Files\nodejs (the standard layout shipped by this installer), a non-elevated installer run gets EPERM from npm install -g --prefix "C:\Program Files\nodejs". The installer then proceeded to the plugin step and bailed with 未找到 openclaw 命令,无法安装插件.

Changes

  1. deployer/windows_setup.py — pick a writable npm prefix. New _choose_npm_install_prefix() probes self.node_dir for writability and falls back to %APPDATA%\npm (the standard per-user npm prefix) when blocked. The Electron desktop's resolveOpenClawEntry already searches that path, so no resolver changes are needed.

  2. deployer/windows_setup.py — real success verification. The previous heuristic considered the install successful if 'openclaw' in npm_output, but that substring is matched by npm's cache-hit URLs like npm http cache https://registry.npmjs.org/openclaw even on EPERM failure. Replaced with an actual filesystem check for the openclaw entry under the chosen prefix; if absent the install is reported as failed with the tail of npm's output.

  3. deployer/windows_setup.py — broaden lookup helpers. _find_openclaw_cmd, check_openclaw_windows, _patch_pi_ai_usage_streaming, and warmup_compile_cache now also search the chosen install_prefix and %APPDATA%\npm.

  4. appcontainer/sandbox-state.js — sandbox allow-list. Added %APPDATA%\npm to _safePaths so the gateway child process can read openclaw.mjs from the fallback location instead of being rejected with EACCES: sandbox unauthorized directory, read blocked (which previously froze the desktop at ~70%% during startup).

  5. build.ps1 — friendlier node detection. Falls back to Get-Command node.exe when node isn't in the three hard-coded MSI/legacy directories, and the failure message now lists every location that was searched.

Testing

  • Reproduced the original failure on a non-elevated install with Node.js MSI under C:\Program Files\nodejs: npm install -g failed with EPERM and the installer incorrectly reported success.
  • After fix: _choose_npm_install_prefix falls back to %APPDATA%\npm, the install succeeds, _find_openclaw_cmd resolves the binary, the plugin step completes, and the desktop gateway loads openclaw.mjs from inside the AppContainer sandbox.

…is read-only

When the Node.js MSI is installed per-machine (default at C:\Program Files\nodejs), a non-elevated installer process gets EPERM trying to npm install -g into that directory. Three related fixes:

1. deployer/windows_setup.py: add _choose_npm_install_prefix() that probes writability of node_dir and falls back to the standard per-user prefix %APPDATA%\npm. The Electron desktop's resolveOpenClawEntry already searches that path, so no resolver changes are needed.

2. deployer/windows_setup.py: replace the bogus success heuristic ('openclaw' substring in npm output) with actual entry-file verification. The substring matched npm's cache-hit URLs (npm http cache https://registry.npmjs.org/openclaw) and so reported success even when install had failed with EPERM, causing a confusing 'openclaw command not found' later in the plugin step.

3. appcontainer/sandbox-state.js: add %APPDATA%\npm to the sandbox _safePaths allow-list so the gateway child process can load openclaw.mjs from the new location without EACCES.

Also: build.ps1 now falls back to Get-Command node.exe when node isn't in the three standard install locations, and surfaces a clearer error listing every place it looked.

_uninstall_clean_node still removes any system-installed Node.js as before; that behaviour is unchanged in this PR.
@taoyizhi68 taoyizhi68 merged commit 11c4e29 into microsofthackathons:main May 15, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant