Skip to content

fix(init): clean up data and config directories during uninstall - #1020

Closed
andeart wants to merge 10 commits into
rtk-ai:developfrom
andeart:fix/uninstall-data-dir-cleanup
Closed

andeart wants to merge 10 commits into
rtk-ai:developfrom
andeart:fix/uninstall-data-dir-cleanup

Conversation

@andeart

@andeart andeart commented Apr 4, 2026 •

Copy link
Copy Markdown

Summary

Fixes #1014.

  • rtk init -g --uninstall now removes the RTK data directory (~/.local/share/rtk/ on Linux, ~/Library/Application Support/rtk/ on macOS) - covers history.db, trusted_filters.json, .hook_warn_last, .telemetry_last_ping, .device_salt, and tee/
  • Also removes the RTK config directory (~/.config/rtk/ on Linux) - covers config.toml and filters.toml
  • When history.db exists, prompts for confirmation before deleting (with a note to export via rtk gain --history first). In non-interactive mode (piped stdin), skips data directory removal entirely to avoid silent data loss.

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test. 1348 tests pass, 0 failures. Clippy warnings are all pre-existing in unrelated files.
  • 7 new unit tests cover: data dir cleanup (happy path + noop + full artifact reporting), config dir cleanup (happy path + noop), and an integration test asserting all 6 known data artifacts are individually reported.
  • Tests pass interactive: false to bypass the stdin prompt; production call site passes interactive: true.
  • Default calls tested manually.
    • Built source with cargo build --release
    • target/release/rtk init -g to install, then target/release/rtk init -g --uninstall
    • A [y/N] prompt appears before deleting history.db. Answering N skips data dir removal, answering y removes it. Hooks are removed in either case (I felt this was okay given the user explicitly started this uninstall command anyhow).
  • Tested manually: non-interactive mode (echo "" | rtk init -g --uninstall) skips data directory removal with a message.
  • Tested manually: a fresh rtk init -g after uninstall works cleanly (no leftover state interference).

Important: All PRs must target the develop branch (not master).
See CONTRIBUTING.md for details.

@andeart
andeart marked this pull request as ready for review April 4, 2026 17:52
@andeart andeart changed the title Clean up data and config directories during uninstall fix(init): clean up data and config directories during uninstall Apr 4, 2026
@pszymkowiak

Copy link
Copy Markdown
Collaborator

Thanks @andeart — #1014 is real and still present on develop. The fix looks well done at a glance (cross-platform dirs, interactive guard before deleting history.db, tests). But the branch is 338 commits behind develop and never rebased. Could you rebase onto develop first? I'll do a full review on the up-to-date code afterwards. One thing to consider meanwhile: remove_dir_all wipes the whole dir — fine since rtk owns it, just flagging it.

@rtk-release-bot

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale due to 90 days of inactivity. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. Your contribution is very much appreciated — we're sorry we haven't been able to review it yet.

@rtk-release-bot rtk-release-bot Bot added the stale label Sep 3, 2026
@andeart andeart closed this Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk init -g --uninstall leaves data directory artifacts on disk

2 participants