fix(uninstall): preserve user-installed Node.js#5
Merged
Conversation
The MicroClaw uninstaller previously ran _msi_uninstall_node and rmtree'd the Node install directory unconditionally — matching any MSI entry whose DisplayName contained 'node.js'. This wiped Node.js even when the user had installed it themselves before installing MicroClaw, breaking subsequent `build.ps1` runs that depend on a pre-existing Node.js. Now install_node_windows writes ~/.openclaw/.node-installed-by-microclaw recording the install path when MicroClaw itself installs Node via MSI. _uninstall_clean_node and _msi_uninstall_node consult this marker: - No marker -> skip MSI uninstall, skip rmtree of self.node_dir, skip removing %APPDATA%\npm from PATH. The legacy ~/.openclaw-node dir is still cleaned (always ours). - Marker present -> only uninstall MSI entries whose InstallLocation matches the recorded path, and only rmtree that path + legacy dirs.
taoyizhi68
added a commit
that referenced
this pull request
May 15, 2026
The MicroClaw uninstaller previously ran _msi_uninstall_node and rmtree'd the Node install directory unconditionally - matching any MSI entry whose DisplayName contained 'node.js'. This wiped Node.js even when the user had installed it themselves before installing MicroClaw, breaking subsequent `build.ps1` runs that depend on a pre-existing Node.js. Now install_node_windows writes ~/.openclaw/.node-installed-by-microclaw recording the install path when MicroClaw itself installs Node via MSI. _uninstall_clean_node and _msi_uninstall_node consult this marker: - No marker -> skip MSI uninstall, skip rmtree of self.node_dir, skip removing %APPDATA%\npm from PATH. The legacy ~/.openclaw-node dir is still cleaned (always ours). - Marker present -> only uninstall MSI entries whose InstallLocation matches the recorded path, and only rmtree that path + legacy dirs.
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.
Problem
Uninstalling MicroClaw via the desktop Uninstall MicroClaw shortcut removes Node.js even when the user installed it themselves before installing MicroClaw. After uninstall,
build.ps1fails with:The cause is in _msi_uninstall_node: it enumerates HKCU/HKLM Uninstall registry entries and runs
msiexec /xon any entry whoseDisplayNamecontainsnode.js, then_uninstall_clean_nodermtree'sself.node_dir(typicallyC:\Program Files\nodejs). It has no way to tell apart "Node we installed" from "Node the user installed".Fix
Add an ownership marker:
install_node_windowswrites~/.openclaw/.node-installed-by-microclawcontaining the install path on a successful MSI install._uninstall_clean_nodereads the marker:rmtreeofself.node_dir, skip removing%APPDATA%\npmfrom PATH. The legacy~/.openclaw-nodedirectory is still cleaned (always ours)._msi_uninstall_nodenow requires the recorded path and additionally filters registry entries byInstallLocation, so unrelated Node MSIs are never touched.Matrix
~/.openclaw-nodeTest
Repro before fix:
C:\Program Files\nodejsbuild.ps1-> fails: node.exe not foundAfter fix: step 4 succeeds; the user's Node.js remains intact.