Skip to content

feat(installer): implement uninstall, fix update components on MacOS - #663

Merged
twitchyliquid64 merged 1 commit into
mainfrom
tom/uninstall
Jul 8, 2026
Merged

feat(installer): implement uninstall, fix update components on MacOS#663
twitchyliquid64 merged 1 commit into
mainfrom
tom/uninstall

Conversation

@twitchyliquid64

@twitchyliquid64 twitchyliquid64 commented Jul 7, 2026

Copy link
Copy Markdown
Member
  • Implement --uninstall
  • Fix bug where components with updates were not updated on OSX

Summary by CodeRabbit

  • New Features

    • Added an offline --uninstall mode to the installer.
    • Added support for --force, --purge, and --dry-run during uninstall.
  • Bug Fixes

    • Improved reinstall behavior on macOS so signed binaries are re-downloaded when the installed bytes no longer match the expected release.
    • Uninstall now safely skips modified files unless forced, and handles repeated or empty uninstalls cleanly.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: acc98772-e329-4e53-bd21-15f4ac70e166

📥 Commits

Reviewing files that changed from the base of the PR and between e8fe0af and f279178.

📒 Files selected for processing (3)
  • docs/specs/07-spec-installer/07-spec-installer.md
  • scripts/install.sh
  • scripts/install_test.sh
 ___________________________________________________________________
< Your feature is behind a flag. Your bug is already in production. >
 -------------------------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
putComment timed out

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (2)
scripts/install.sh (1)

379-388: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider a shared helper for the record row format.

The 4-column tab-delimited printf used to write a record row is duplicated at the skip path (388) and the fresh-install path (428). This format is the uninstaller's sole contract (R7.3/R7.4), so keeping both writers in sync matters; a small helper removes the duplication risk.

♻️ Proposed refactor
+write_record() {
+    printf '%s\t%s\t%s\t%s\n' "$1" "$2" "$3" "$4" >>"$records"
+}
+
 ...
-            printf '%s\t%s\t%s\t%s\n' "$comp" "$target_file" "$want" "$on_disk" >>"$records"
+            write_record "$comp" "$target_file" "$want" "$on_disk"
 ...
-    printf '%s\t%s\t%s\t%s\n' "$comp" "$target_file" "$want" "$(sha256 "$target_file")" >>"$records"
+    write_record "$comp" "$target_file" "$want" "$(sha256 "$target_file")"

Also applies to: 425-428

🤖 Prompt for 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.

In `@scripts/install.sh` around lines 379 - 388, The 4-column tab-delimited record
row format is duplicated between the skip path and the fresh-install path, so
centralize it behind a shared helper in scripts/install.sh. Add a small helper
used by the existing up-to-date branch and the install branch to emit the record
row, keeping the uninstaller contract consistent and preventing the two `printf`
call sites from drifting out of sync.
scripts/install_test.sh (1)

429-440: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Missing coverage for --purge combined with a kept (unremoved) entry.

All purge scenarios here (u5_plain/u5_purge) have a fully-clean footprint (no modified/foreign files), so they don't exercise the case where kept_modified/kept_foreign > 0 and --purge is also passed — exactly the scenario in the scripts/install.sh do_uninstall review comment where the retained install record gets wiped by the purge step. Worth adding a scenario: seed an install, replace a recorded bin file with a directory (foreign) or leave a modified file with --force omitted, then run --uninstall --purge, and assert the record's fate matches intended behavior once the fix above lands.

🤖 Prompt for 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.

In `@scripts/install_test.sh` around lines 429 - 440, Add coverage for the
`--uninstall --purge` path when some install-record entries are intentionally
kept, since the current `u5_plain`/`u5_purge` cases only cover fully clean
trees. In `scripts/install_test.sh`, extend the
`u5_install`/`u5_plain`/`u5_purge` flow with a scenario that introduces a kept
entry such as a modified or foreign `bin` target, then runs `--uninstall
--purge` and asserts the expected record and cache-tree outcome. Reference the
`u5_plain`, `u5_purge`, and `run` helpers so the new test clearly exercises the
`do_uninstall` behavior under kept entries.
🤖 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 `@docs/specs/07-spec-installer/07-spec-installer.md`:
- Around line 515-521: R8.2 currently says --purge removes the resolved state
tree in full, but that conflicts with the install-record retention rule from
R8.1 when kept_modified or kept_foreign entries remain. Update the R8.2 wording
in the spec to add an explicit carve-out for the state directory/record so purge
does not delete the inventory that was intentionally retained, and make the
exception consistent with the existing R8.1 and Design Considerations language.

In `@scripts/install.sh`:
- Around line 228-241: The --purge cleanup in install.sh is deleting the
retained install record by removing the entire state tree even when
kept_modified or kept_foreign caused the record to be preserved earlier. Update
the purge loop to avoid blindly purging resolve_prefix("state") when a record
must be retained, and keep the record-teardown logic in sync with the purge path
so the inventory remains available for later --force or manual cleanup. Use the
existing uninstall_purge block and the kept_modified/kept_foreign
record-retention flow to decide whether state should be skipped or handled
separately.
- Around line 243-260: The uninstall cleanup in install.sh prunes directories
via the bin/data/state/cache loop, but nothing reports which ones were actually
removed, so R8.4’s summary is incomplete. Update the uninstall path around the
rmdir loop and the final say summary to track pruned directories and include
that information in the reported outcome, using the existing uninstall flow
symbols like resolve_prefix, rmdir, say, and the removed/absent/kept counters.

---

Nitpick comments:
In `@scripts/install_test.sh`:
- Around line 429-440: Add coverage for the `--uninstall --purge` path when some
install-record entries are intentionally kept, since the current
`u5_plain`/`u5_purge` cases only cover fully clean trees. In
`scripts/install_test.sh`, extend the `u5_install`/`u5_plain`/`u5_purge` flow
with a scenario that introduces a kept entry such as a modified or foreign `bin`
target, then runs `--uninstall --purge` and asserts the expected record and
cache-tree outcome. Reference the `u5_plain`, `u5_purge`, and `run` helpers so
the new test clearly exercises the `do_uninstall` behavior under kept entries.

In `@scripts/install.sh`:
- Around line 379-388: The 4-column tab-delimited record row format is
duplicated between the skip path and the fresh-install path, so centralize it
behind a shared helper in scripts/install.sh. Add a small helper used by the
existing up-to-date branch and the install branch to emit the record row,
keeping the uninstaller contract consistent and preventing the two `printf` call
sites from drifting out of sync.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: acc98772-e329-4e53-bd21-15f4ac70e166

📥 Commits

Reviewing files that changed from the base of the PR and between e8fe0af and f279178.

📒 Files selected for processing (3)
  • docs/specs/07-spec-installer/07-spec-installer.md
  • scripts/install.sh
  • scripts/install_test.sh

Comment thread docs/specs/07-spec-installer/07-spec-installer.md
Comment thread docs/specs/07-spec-installer/07-spec-installer.md
Comment thread scripts/install.sh
Comment thread scripts/install.sh
@twitchyliquid64
twitchyliquid64 enabled auto-merge (squash) July 8, 2026 00:12

@bryan-minimal bryan-minimal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, only small issue would be someone who used the old version of this installer, but this isn't in use yet.

@twitchyliquid64
twitchyliquid64 merged commit 15b86ac into main Jul 8, 2026
109 checks passed
@twitchyliquid64
twitchyliquid64 deleted the tom/uninstall branch July 8, 2026 00:16
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