Prune the package cache before updating - #6734
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds safe pacman cache pruning before snapshots and package updates.
Changes:
- Keeps two cached package versions via
paccache -rk2. - Treats pruning failures as non-fatal.
- Tests retention, failure handling, ordering, and updater isolation.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
bin/omarchy-update |
Runs cache pruning before snapshot creation. |
bin/omarchy-update-pkg-cache |
Implements non-fatal cache pruning. |
test/shell.d/update-pkg-cache-test.sh |
Tests pruning arguments, failure, and ordering. |
test/shell.d/update-disk-space-test.sh |
Stubs pruning during updater tests. |
test/shell.d/update-lock-test.sh |
Stubs pruning during lock tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
dhh
force-pushed
the
trim-package-cache-during-update
branch
from
August 12, 2026 09:44
9e48d45 to
54e92aa
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (1)
test/shell.d/update-pkg-prune-test.sh:34
- This regex also accepts values such as
-rk20, so a regression that retains far more than the intended two versions could still pass while defeating the pruning goal. Compare the recorded invocation exactly withpaccache -rk2so the retention contract is pinned.
grep -qE 'paccache .*-rk2' "$test_tmp/args" ||
dhh
force-pushed
the
trim-package-cache-during-update
branch
from
August 12, 2026 09:51
54e92aa to
1de9186
Compare
The pacman cache grows without bound across updates, and nothing in the update flow ever reclaimed it. On a machine that has been updating for a while it reaches several gigabytes of superseded versions that nothing will ever install again. Prune it with paccache -rk2 as the first step of an update. Both halves of that placement are load-bearing. Keeping two versions rather than one preserves the rollback path. The cache is Arch's only offline downgrade: when an update breaks a single package, reinstalling its predecessor from here is the surgical fix, where a snapshot rollback would revert every other package too. Pruning before the packages update means the installed version is still the newest cached, so it survives along with a spare. Retention is by version order and never consults what is installed, so that holds while the installed version is among the two newest cached; a deliberate downgrade or repeated failed transactions can stack newer archives on top of it. Running before the snapshot is what actually frees the space. The cache sits on the snapshotted root subvolume, so a prune taken afterwards leaves the fresh snapshot holding those extents and reclaims nothing until it ages out of the number cleanup. A failed prune warns and continues. Cache housekeeping should not trip the update's ERR trap and tell the user their update went wrong. This runs after omarchy-update-requires-free-space, so it reclaims space during healthy updates but does not rescue a machine already under the 10 GiB gate. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
dhh
force-pushed
the
trim-package-cache-during-update
branch
from
August 12, 2026 09:55
1de9186 to
dc936d8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The pacman cache grows without bound across updates and nothing in the update flow ever reclaimed it. On this machine it had reached 7.4G across 732 archives, ~3.75 GiB of which are superseded versions nothing will install again.
Adds
omarchy-update-pkg-prune, runningpaccache -rk2as the first step of an update.Why that placement
Both halves of it are load-bearing.
Before the packages update. The cache is Arch's only offline downgrade path — when an update breaks one package, reinstalling its predecessor from here is the surgical fix, where a snapshot rollback reverts every other package too. Pruning beforehand means the installed version is still the newest cached, so it survives along with a spare. Pruning after would make the newest cached version the freshly installed one, and cutting down to a single copy would delete exactly what a broken update needs.
Before the snapshot. The cache sits on the snapshotted root subvolume, so a prune taken after
omarchy-snapshot createleaves the fresh snapshot holding those extents and reclaims nothing until it ages out of the number cleanup. Ordering it first is what makes the space actually come back.-k2reclaims 3.75 GiB here, against 4.95 for-k1(which leaves no rollback candidate) and 3.11 for-k3.Failure handling
A failed prune warns and continues rather than aborting. Cache housekeeping shouldn't trip the update's ERR trap and tell the user their update went wrong. This got exercised for real: an early test run hit the unstubbed command with no sudo password available, and it warned and carried on with the cache untouched.
Known limitations
Two things this deliberately does not do, both worth a second opinion:
omarchy-update-requires-free-space, so it reclaims space during healthy updates but does not rescue a machine already under the 10 GiB gate — the case where the cache itself is what's blocking the update. Folding the prune into that gate and rechecking would fix it, at the cost of mutating the system before the user confirms.paccacheretains by version order and never consults what is installed. The rollback guarantee therefore holds only while the installed version is among the two newest cached. A deliberate downgrade held withIgnorePkg, or repeated failed transactions, can stack newer archives on top of the installed one, and its copy becomes prunable like any other. Exempting installed versions is possible but needs real filename parsing.Not included:
paccache -ruk0for uninstalled packages, which is strictly safe and pairs naturally withomarchy-update-orphan-pkgs.Testing
New
test/shell.d/update-pkg-prune-test.shcovers the keep count, the non-fatal failure path, and both ordering invariants by asserting line order inomarchy-update.Also stubs the new command in
update-disk-space-test.shandupdate-lock-test.sh, both of which execute the real updater. Without that,./test/shellreaches a realsudo paccache -rk2and would prune the developer's own cache on a box with passwordless sudo.update-lock-test.shwas caught by a Codex review pass, not by me../test/shell(160 files) and./test/cliboth green.🤖 Generated with Claude Code