Skip to content

fix(shell): nushell uninstall cleans all candidate locations, dedup candidates - #1050

Merged
github-actions[bot] merged 2 commits into
mainfrom
1038
Feb 16, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
1038

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Summary

Follow-up fixes to #1038 where config_paths() was changed to return multiple Nushell candidates but not all consumers were updated:

  • Uninstall iterates all candidate paths instead of only paths.first(), so config files installed at a different location (e.g., nu was in PATH during install but not during uninstall) get cleaned up
  • has_config_location checks any candidate's parent directory for auto-detection, not just the first
  • Deduplicated nushell_config_candidates() — removed redundant etcetera entry (always duplicated either $XDG_CONFIG_HOME/nushell or ~/.config/nushell) and added HashSet-based dedup for remaining edge cases

Test plan

  • New integration test test_uninstall_nushell_cleans_all_candidate_locations — installs at default location, copies to secondary candidate, uninstalls with different XDG_CONFIG_HOME, verifies both files removed
  • New unit test test_nushell_config_candidates_no_duplicates — verifies no duplicate paths
  • Updated test_nushell_config_candidates_always_has_fallback — platform-aware assertions
  • All existing nushell tests pass (install, uninstall, auto-detection)
  • Full test suite (1033 tests), lints, clippy all green

This was written by Claude Code on behalf of @max-sixty

…andidates

Follow-up fixes to #1038 where config_paths() was changed to return
multiple Nushell candidates but not all consumers were updated:

- Uninstall now iterates all candidate paths instead of only the first,
  so config files installed at a different location (e.g., nu was in PATH
  during install but not during uninstall) get cleaned up
- has_config_location checks any candidate's parent directory for
  auto-detection, not just the first
- Removed redundant etcetera entry from nushell_config_candidates() (always
  duplicated either $XDG_CONFIG_HOME/nushell or ~/.config/nushell) and added
  HashSet-based dedup for remaining edge cases

Co-Authored-By: Claude <[email protected]>
Deduplicate 4 identical remove_file + map_err + format! patterns into
a shared remove_config_file() helper. Improves patch coverage by making
the nushell uninstall block a simple function call.

Co-Authored-By: Claude <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Clean, well-motivated fix. The core bug was real — Nushell uninstall only checked paths.first(), so config files installed at a different candidate location (e.g., when nu was available during install but not uninstall) would be orphaned. The fix correctly iterates all candidates, and the remove_config_file helper is a good dedup of the four identical error-formatting blocks.

A few observations:

Design notes (3 items)

Nushell doesn't check is_worktrunk_managed_content — and that's fine. Fish uses shared config files (wt.fish in functions/) that could theoretically be user-created, so it validates content before deleting. Nushell config lives at vendor/autoload/wt.nu, a worktrunk-specific file, so content validation would be pointless overhead.

remove_config_file returns Result<(), String> instead of Result<(), anyhow::Error>. This matches the existing scan_for_uninstall signature which already returns Result<..., String>. Consistent with the current design, though the broader String-based error pattern in this function is a candidate for future cleanup.

Dedup of nushell_config_candidates — removing the etcetera entry. The removed choose_base_strategy().config_dir() always resolved to either $XDG_CONFIG_HOME or ~/.config on Linux (and ~/Library/Application Support on macOS), which the remaining fallbacks already cover. The HashSet dedup handles any remaining overlap cleanly.

Test observations

The new integration test test_uninstall_nushell_cleans_all_candidate_locations is well-structured — it installs at the default location, copies the config to a secondary candidate, then uninstalls with a different XDG_CONFIG_HOME and verifies both are cleaned up. This directly exercises the bug scenario.

The test_nushell_config_candidates_no_duplicates unit test is a useful invariant check that will catch regressions if new candidate paths are added.

The updated test_nushell_config_candidates_always_has_fallback correctly relaxes the assertion from "at least 2" to "at least 1" on non-macOS, since the etcetera entry was removed. The #[cfg(target_os = "macos")] guard for the >= 2 assertion is appropriate.

Looks good to merge once CI is green.

@github-actions github-actions 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.

All CI checks green (tests on Linux/macOS/Windows, codecov/patch, lint). Clean fix, good test coverage. Approving.

@github-actions
github-actions Bot merged commit f4ce6d1 into main Feb 16, 2026
20 of 21 checks passed
@github-actions
github-actions Bot deleted the 1038 branch February 16, 2026 05:15
@max-sixty

Copy link
Copy Markdown
Owner Author

CC @arnaudlimbourg

Repository owner deleted a comment from github-actions Bot Feb 16, 2026

This branch was previously deployed

1 inactive deployment
claude-review — e1544c2c Deployed Feb 16, 2026 by max-sixty via review #32
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