Repository navigation
fix(windows): remove dangling runtime symlink pointer files on uninstall - #11095
Conversation
On Windows runtime symlinks are regular files containing the relative target path, so the `!path.exists()` check in remove_missing_symlinks_in_dir never fired and stale version pointer files (e.g. `16`, `16.20`, `latest`) were left behind after `mise uninstall`. Resolve the stored target and check its existence instead, which on unix is equivalent to following the symlink. Fixes jdx#5260 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Caution Review failedAn error occurred during the review process. Please try again later. 📝 WalkthroughWalkthroughRuntime symlink cleanup now resolves stored targets when identifying missing pointers. Unit tests and Windows end-to-end tests cover dangling pointer removal, preservation of valid versions, and deletion of the final tool directory. ChangesRuntime symlink cleanup
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR fixes a Windows-only bug where partial-version pointer files (
Confidence Score: 5/5Safe to merge — the fix is narrowly scoped to the dangling-pointer removal path and on Unix it is a no-op semantic change. The change replaces one well-understood existence check with an equivalent one that also works on Windows. On Unix, installs_dir.join(target).exists() resolves to the same path as the old path.exists() symlink-follow, so there is no regression risk on that platform. The extracted helper and new unit tests directly exercise the bug scenario. No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "fix(windows): address review feedback on..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@e2e-win/uninstall_symlink.Tests.ps1`:
- Around line 21-23: Replace the non-ASCII em dash in the explanatory comment
about Windows version pointer files with a standard ASCII hyphen, leaving the
surrounding comment text and uninstall test behavior unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: 68915f23-70b9-47ec-80b9-03796c223214
📒 Files selected for processing (2)
e2e-win/uninstall_symlink.Tests.ps1src/runtime_symlinks.rs
- resolve the symlink target once per entry via a new runtime_symlink_target helper instead of resolving twice (is_runtime_symlink + resolve_symlink) - make the last-version e2e test independent of the previous test by using `mise uninstall --all yq` - replace a non-ASCII em-dash in the e2e script comment (PSScriptAnalyzer PSUseBOMForUnicodeEncodedFile) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary
path.exists()on the pointer itselfremove_missing_symlinks_in_dir(none existed)Context
Fixes #5260.
On Windows, runtime "symlinks" (the partial-version pointers like
16,16.20,latestininstalls\<tool>\) are regular files containing the relative target path (make_symlink_or_file). The cleanup inremove_missing_symlinks_in_dirgated removal onis_runtime_symlink(&path) && !path.exists()— on unixexists()follows the real symlink and turns false once the target is gone, but on Windows the pointer is an ordinary file that always exists, so stale pointers were never removed aftermise uninstall. The leftover files also keptremove_dir_ignorefrom removing the now-empty tool directory.The fix resolves the stored target via
file::resolve_symlinkand checks that against the installs dir, which is exactly whatexists()computed on unix (runtime symlink targets are always./-relative to the installs dir), so unix behavior is unchanged.Reproduced on Windows 11 with v2026.7.7 in an isolated
MISE_DATA_DIR:Tests
cargo fmt --checkcargo test remove_missing_symlinks(fail on Windows before the fix, pass after; pass on unix both before and after, documenting parity)e2e-win/uninstall_symlink.Tests.ps1: installs two yq versions, uninstalls one, asserts the stale pointer is gone while the remaining version's pointers survive; then asserts the tool dir disappears when the last version is uninstalledThis PR was prepared by an AI coding assistant.
Summary by CodeRabbit
latestpointer.