Fix: keep appdata binary cache in sync with background self-updates - #4
Open
2CrAzYTV wants to merge 1 commit into
Open
Fix: keep appdata binary cache in sync with background self-updates#42CrAzYTV wants to merge 1 commit into
2CrAzYTV wants to merge 1 commit into
Conversation
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
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.
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'scache_binary()is only evercalled right after a fresh install (inside
install_claude_code()'snative-installer branch), so any later self-update never reaches the
appdata cache.
Effect: after a reboot,
restore_cached_binary()restores the oldpre-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 standardmechanism
update_cronpicks up, same as other plugins under/boot/config/plugins/*/*.cron) and reloads it. The cron entry runs anew
sync-cache.shscript every 15 minutes, which does a cheapcmpagainst 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-versionconvention.Testing
Reproduced and verified on my own Unraid box: after a background
self-update,
/root/.local/bin/claudeand the appdata-cached copy haddiverged (confirmed via
cmp/version check). Applied this fix, confirmedthe cron entry lands in the live crontab via
update_cron, and thatsync-cache.shcorrectly 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