fix(installer): install openclaw to %APPDATA%\npm when Program Files is read-only#3
Merged
taoyizhi68 merged 1 commit intoMay 15, 2026
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 getsEPERMfromnpm install -g --prefix "C:\Program Files\nodejs". The installer then proceeded to the plugin step and bailed with未找到 openclaw 命令,无法安装插件.Changes
deployer/windows_setup.py— pick a writable npm prefix. New_choose_npm_install_prefix()probesself.node_dirfor writability and falls back to%APPDATA%\npm(the standard per-user npm prefix) when blocked. The Electron desktop'sresolveOpenClawEntryalready searches that path, so no resolver changes are needed.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 likenpm http cache https://registry.npmjs.org/openclaweven 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.deployer/windows_setup.py— broaden lookup helpers._find_openclaw_cmd,check_openclaw_windows,_patch_pi_ai_usage_streaming, andwarmup_compile_cachenow also search the choseninstall_prefixand%APPDATA%\npm.appcontainer/sandbox-state.js— sandbox allow-list. Added%APPDATA%\npmto_safePathsso the gateway child process can readopenclaw.mjsfrom the fallback location instead of being rejected withEACCES: sandbox unauthorized directory, read blocked(which previously froze the desktop at ~70%% during startup).build.ps1— friendlier node detection. Falls back toGet-Command node.exewhennodeisn't in the three hard-coded MSI/legacy directories, and the failure message now lists every location that was searched.Testing
C:\Program Files\nodejs:npm install -gfailed withEPERMand the installer incorrectly reported success._choose_npm_install_prefixfalls back to%APPDATA%\npm, the install succeeds,_find_openclaw_cmdresolves the binary, the plugin step completes, and the desktop gateway loadsopenclaw.mjsfrom inside the AppContainer sandbox.