Skip to content

fix(prune): preserve runtime symlinks during dry runs - #11017

Merged
jdx merged 2 commits into
jdx:mainfrom
risu729:agent/prune-dry-run-symlinks
Jul 16, 2026
Merged

jdx merged 2 commits into
jdx:mainfrom
risu729:agent/prune-dry-run-symlinks

Conversation

@risu729

@risu729 risu729 commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • keep runtime-symlink cleanup behind the same dry-run guard as version removal
  • retain the existing uninstall/remove preview output
  • cover both --dry-run and --dry-run-code

Root cause

Backend uninstall correctly skipped deletion in dry-run mode, but the following runtime-symlink cleanup call was unconditional and could remove dangling generated symlinks.

Tests

  • cargo fmt --all -- --check
  • git diff --check
  • mise run test:e2e e2e/cli/test_prune

Summary by CodeRabbit

  • Bug Fixes
    • mise prune --dry-run no longer removes broken runtime symlinks; existing symlinks remain intact after the command.
    • mise prune --dry-run-code still exits non-zero when prune candidates are present, without performing any pruning or symlink cleanup.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

mise prune --dry-run no longer removes missing runtime symlinks. End-to-end tests verify symlink preservation during dry runs and its updated target after real pruning.

Changes

Prune dry-run behavior

Layer / File(s) Summary
Guard symlink cleanup and validate dry-run behavior
src/cli/prune.rs, e2e/cli/test_prune
Runtime symlink cleanup runs only outside dry-run mode, while CLI tests verify dry-run status, filesystem preservation, and the symlink target after real pruning.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

A rabbit found a dangling vine,
“Dry-run leaves this link just fine.”
Reports may say what pruning could do,
But the link stays safely in view.
Real pruning later sets it right—
Hop, hop, tested day and night!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: prune dry runs now preserve runtime symlinks.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug where mise prune --dry-run (and --dry-run-code) would still remove dangling runtime symlinks even though no actual tool versions were uninstalled. The fix is a single if !dry_run guard placed around the runtime_symlinks::remove_missing_symlinks call that follows uninstall_version.

  • src/cli/prune.rs: Wraps runtime_symlinks::remove_missing_symlinks(p) in a !dry_run check, consistent with how uninstall_version already skips deletions in dry-run mode.
  • e2e/cli/test_prune: Introduces a dangling symlink fixture (latest → ./missing) and asserts it survives both --dry-run and --dry-run-code, then verifies it is correctly updated to ./3.0.0 after a real prune.

Confidence Score: 5/5

Safe to merge — the change is a minimal, targeted guard that aligns symlink cleanup with the existing dry-run semantics already applied to version removal.

The fix is a single three-line conditional wrapping an existing call, the logic is straightforward and directly mirrors the dry-run handling already in place for uninstall_version. The new e2e test covers the previously broken path (dangling symlink removed during dry-run) as well as the happy path after a real prune, leaving no obvious gap in coverage.

No files require special attention.

Important Files Changed

Filename Overview
src/cli/prune.rs Adds a !dry_run guard around runtime_symlinks::remove_missing_symlinks(p) so dangling symlinks are preserved during dry-run and dry-run-code executions.
e2e/cli/test_prune Adds a dangling symlink fixture and three new assertions that verify symlinks survive both --dry-run and --dry-run-code, then are correctly cleaned up on a real prune.

Reviews (3): Last reviewed commit: "test(prune): strengthen runtime symlink ..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/cli/test_prune`:
- Around line 10-13: Update the dry-run assertion in the prune test to verify
that the dangling dummy/latest symlink is specifically mentioned in the preview
output, rather than matching the generic “remove” text. Keep the existing
symlink-preservation assertion and ensure the test distinguishes this cleanup
candidate from earlier tool-version removals.
🪄 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: e4676391-d4e5-4ee7-b0de-86facb53f97f

📥 Commits

Reviewing files that changed from the base of the PR and between d2276c3 and a26eba8.

📒 Files selected for processing (2)
  • e2e/cli/test_prune
  • src/cli/prune.rs

Comment thread e2e/cli/test_prune Resolved
@risu729
risu729 force-pushed the agent/prune-dry-run-symlinks branch from a26eba8 to 52822b4 Compare July 16, 2026 04:58
@risu729
risu729 marked this pull request as ready for review July 16, 2026 05:25
@jdx
jdx merged commit bf6399c into jdx:main Jul 16, 2026
33 checks passed
@risu729
risu729 deleted the agent/prune-dry-run-symlinks branch July 16, 2026 14:51
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.

2 participants