Repository navigation
fix(cli): make nodespace uninstall stop the daemon and drop the autorun entry on Windows - #4248
Merged
Merged
Conversation
…orun entry on Windows Replace the Windows refusal with a real uninstall: remove the HKCU Run entry, stop the nodespaced.exe running from this install's bin/bin-dev directories (matched by full executable path, then waited on), and remove the install tree file by file so a locked executable is reported by name instead of aborting the rest. Steps that fail are returned from the user-home removal and fail the command with a non-zero exit and no success line, together with any path that could not be removed. The autorun key and value names move to nodespace-proto so the app and the CLI share one definition. Non-Windows behaviour is unchanged. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…table is left The usual Windows uninstall runs the staged nodespace.exe, which Windows will not delete while it runs, so the command always failed. When that file is the only path that could not be removed and no step failed, hand it (and the bin directories) to a hidden helper that waits for this process to exit and then removes them, say so, and succeed. Any other leftover, or a failed step, still fails the command, the running file included. Also start reg.exe and powershell.exe from the system directory, report a `reg query` failure other than a missing value instead of treating it as absent, and pass image names and directories separated by newlines. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
mstomar125
force-pushed
the
issue-4050-uninstall
branch
from
November 5, 2026 11:07
222bc7e to
4c81548
Compare
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.
Closes #4050
What changed
nodespace uninstallon Windows no longer refuses; it now does the work: removes theHKCU\...\RunNodeSpaceDaemonvalue (reg.exe, presence checked first so "not present" is not an error), then stops thenodespaced.exeprocesses whose executable path is under this install'sbin/bin-devdirectories (PowerShellGet-CimInstance Win32_Process,Stop-Process,Wait-Process; names and directories are passed in environment variables so quoting cannot change the match), inpackages/cli/src/commands/uninstall_windows.rs.incomplete_message).remove_tree_collecting), becauseremove_dir_allstops at the first locked file (for example the runningnodespace.exe); only the files in use remain and each is named.nodespace_proto::socketso the app and the CLI share one definition.stop_daemonreturns no problems).Verification on the real Windows 11 PC
The CLI crate cannot build there (it depends on the daemon, which pulls the NLP engine and needs libclang), so a standalone harness compiled the real
uninstall_windows.rsbyte for byte and the realuninstall(),remove_bin_dir,remove_tree_collectingandstop_daemontext extracted from this branch, with a throwaway Run value (NodeSpaceVerifyTest) and a throwaway daemon image (nsverify-daemon.exe), plus a decoy of the same image name outsidebinand a second process inbinstanding in for the runningnodespace.exe.remove_dir_all+ unconditional success line): the daemon kept running, the Run value stayed,binwas not removed, the command printed "NodeSpace uninstalled." and exited 0.bin: stopped 1 daemon (the decoy outsidebinand the other process were untouched), the Run value was removed, the daemon exe was removed,binkept only the locked file, the command returnedErrnaming that file ("Access is denied. (os error 5)") and exited 1 with no success line.bingone,databasepreserved, success line printed, exit 0.NodeSpaceDaemonvalue was never touched (none existed).Tests (Mac)
cargo test -p nodespace-cli --lib commands::uninstall: 28 passed. New:uninstall_fails_and_names_a_step_that_could_not_complete,incomplete_message_lists_steps_and_paths,remove_tree_collecting_keeps_going_past_a_file_it_cannot_remove,remove_tree_collecting_removes_a_whole_tree_and_ignores_a_missing_one. The old Windows refusal test is removed with the refusal.uninstallfails 1; breaking out after the first undeletable file fails the keep-going test.cargo fmt --checkandcargo clippy -p nodespace-cli -p nodespace-proto --all-targets -D warningsclean.cargo checkofnodespace-app-lib(which uses the moved constants) passed on the PC with the gnu toolchain.What only a full Windows app run could prove
That
nodespace.exebuilt from this branch, run from~\.nodespace\binagainst a real installednodespaced.exeand the app's real autorun entry, behaves as the harness did (the realnodespaced.execould not be built or run on the PC: no libclang). When the runningnodespace.exeitself sits inbinit cannot delete itself; the command reports that file and the user removes it after the command exits.Follow-up commit: the running executable
The usual Windows uninstall runs the staged
nodespace.exe, which cannot be deleted while it runs. When that file is the ONLY path that could not be removed and no step failed, the command now hands it (and the bin directories) to a hidden helper (powershell.exe,CREATE_NO_WINDOW, own process group) that waits for the parent pid, deletes the file with retries, then the empty directories; it prints " is in use by this command and will be removed when it exits." and exits 0. Any other leftover, or a failed step, still exits 1 and names every path, the running file included. Also:reg.exe/powershell.exeare started from%SystemRoot%\System32; areg queryfailure other than a missing value is reported (key must query OK, then value query exit 1 = absent); names and directories are passed newline-separated.PC evidence (real Windows 11, the running image is the harness exe copied to
binand executed from there; the realuninstall_deferring,only_the_running_image_remains,remove_tree_collecting,uninstall_windows.rstext):binand the exe gone right after the child exited and still gone 4 s later, Run value removed, database kept, daemon stopped, decoy untouched.remove_autorun: absent value givesOk(false); a missing key gives an error carrying reg's message.Tests (Mac):
commands::uninstall33 passed. New:only_the_running_image_remains_classifies_the_leftovers,uninstall_defers_the_running_image_when_it_is_all_that_is_left,uninstall_still_fails_when_something_else_is_left_beside_the_image,uninstall_does_not_defer_when_a_step_failed,uninstall_fails_when_the_deferred_removal_cannot_be_scheduled. Mutations caught: classification always true (2 fail), any single failure counts (1), extra failures allowed (2), defer despite a failed step (1). fmt and clippy -D warnings clean.🤖 Generated with Claude Code