Skip to content

Fix: keep appdata binary cache in sync with background self-updates - #4

Open
2CrAzYTV wants to merge 1 commit into
BrianPugh:mainfrom
2CrAzYTV:fix/cache-sync-after-selfupdate
Open

Fix: keep appdata binary cache in sync with background self-updates#4
2CrAzYTV wants to merge 1 commit into
BrianPugh:mainfrom
2CrAzYTV:fix/cache-sync-after-selfupdate

Conversation

@2CrAzYTV

@2CrAzYTV 2CrAzYTV commented Sep 2, 2026

Copy link
Copy Markdown

Problem

Claude Code updates itself in the background while running (downloads a
new version under ~/.local/share/claude/versions/ and eventually swaps
/root/.local/bin/claude). The plugin's cache_binary() is only ever
called right after a fresh install (inside install_claude_code()'s
native-installer branch), so any later self-update never reaches the
appdata cache.

Effect: after a reboot, restore_cached_binary() restores the old
pre-update binary, and the CLI keeps showing "Restart to update"
indefinitely, no matter how many times you restart the session - the
disk cache and the running binary silently diverge over time.

Fix

Adds install_cron(), which writes a small cron fragment to
/boot/config/plugins/claude-code/claude-code.cron (the standard
mechanism update_cron picks up, same as other plugins under
/boot/config/plugins/*/*.cron) and reloads it. The cron entry runs a
new sync-cache.sh script every 15 minutes, which does a cheap cmp
against the cached copy and only re-copies when the binary actually
changed.

This keeps the appdata cache correct on an ongoing basis instead of only
at install time, so a reboot always resumes from whatever version was
actually running - self-updated or not.

Also updates cron cleanup in the removal section, and bumps the plugin
version/CHANGES entry per the existing bump-my-version convention.

Testing

Reproduced and verified on my own Unraid box: after a background
self-update, /root/.local/bin/claude and the appdata-cached copy had
diverged (confirmed via cmp/version check). Applied this fix, confirmed
the cron entry lands in the live crontab via update_cron, and that
sync-cache.sh correctly re-syncs the cache once the binary changes
(verified with a controlled version bump), with no-op behavior (via
cmp) when nothing changed.

🤖 Generated with Claude Code

Claude Code updates itself in the background while running, but the
plugin only ever cached the binary to appdata right after a fresh
install. Any later self-update was never re-cached, so a reboot
silently restored the pre-update binary and the CLI kept reporting
"restart to update" indefinitely.

Adds a cron job (every 15 min, via /boot/config/plugins/claude-code/*.cron
+ update_cron, the standard Unraid plugin mechanism) that re-caches the
binary whenever it changes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CBC81PCfdDtSPVjDNEjR4h
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