Skip to content

fix(uninstall): clean both PowerShell profiles and stop tests polluting real profiles - #126

Merged
mose-zm merged 2 commits into
mainfrom
dev
Aug 30, 2026
Merged

mose-zm merged 2 commits into
mainfrom
dev

Conversation

@mose-zm

@mose-zm mose-zm commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes post-uninstall PowerShell startup errors (Import-Module ... nvm.psm1 not found) and the root cause behind them.

Bug 1 — uninstall only cleaned ONE PowerShell profile:
install/repair code historically wrote to both the PowerShell 7 (Documents\PowerShell) and Windows PowerShell 5.1 (Documents\WindowsPowerShell) profiles, but remove_from_shell_config only cleaned the one detect_shell_config prefers. The other kept a stale Import-Module, erroring on every shell start after uninstall.

  • Windows: clean both candidate profiles on uninstall/deinit.
  • Strip rules strengthened: nvm.psm1/nvm.sh integration lines are now always removed — including legacy literal-temp-path variants written by old versions (these could not be matched by nvm_dir and accumulated by the hundreds on a real user machine).

Bug 2 — tests polluted real user profiles:
The temp-dir write guard only checked TMPDIR, which never exists on Windows, so un-isolated tests wrote hundreds of literal .tmp* PATH lines into real profiles.

  • New shared guard nvm_dir_in_temp checks TMPDIR/TMP/TEMP; applied to update_shell_config, migrate_rc_to_shim_mode, and init ensure_shell_config.
  • Closed isolation gaps: ps_repair test no longer scans real profiles; install_integrity, use_uninstall, and common::run_isolated_with_home now isolate USERPROFILE too.

Test plan

  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test --all (local, all green)
  • New Windows regression test: uninstall --self cleans both profiles, preserves user content
  • New unit tests: legacy literal-line stripping, temp-guard detection (positive + negative)
  • L3 deep security review: 0 findings
  • CI green on Ubuntu / Windows / macOS

@mose-zm
mose-zm merged commit b434073 into main Aug 30, 2026
5 checks passed
@mose-zm
mose-zm deleted the dev branch August 30, 2026 06:37
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