claude-code - 💡(How to fix) Fix Plugin auto-update deletes old cache dir, breaking ${CLAUDE_PLUGIN_ROOT} in running sessions [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#46915Fetched 2026-04-12 13:29:48
View on GitHub
Comments
2
Participants
2
Timeline
7
Reactions
0
Timeline (top)
labeled ×5commented ×2

When a plugin auto-updates on session start, the old cache directory is deleted and replaced with a new hash-versioned directory. Any already-running session that resolved ${CLAUDE_PLUGIN_ROOT} at startup continues pointing to the deleted path, causing every hook invocation to fail.

Error Message

Plugin cache hashes observed changing multiple times in a single day:

  • 03804b3b2735 -> a7a83f99ce07 -> 150430d80202

Root Cause

When a plugin auto-updates on session start, the old cache directory is deleted and replaced with a new hash-versioned directory. Any already-running session that resolved ${CLAUDE_PLUGIN_ROOT} at startup continues pointing to the deleted path, causing every hook invocation to fail.

Fix Action

Workaround

Created a SessionStart hook that records plugin hashes to a history file and creates symlinks from old hashes to the current version:

ln -s <new_hash> ~/.claude/plugins/cache/claude-plugins-official/hookify/<old_hash>

Code Example

ln -s <new_hash> ~/.claude/plugins/cache/claude-plugins-official/hookify/<old_hash>
RAW_BUFFERClick to expand / collapse

Summary

When a plugin auto-updates on session start, the old cache directory is deleted and replaced with a new hash-versioned directory. Any already-running session that resolved ${CLAUDE_PLUGIN_ROOT} at startup continues pointing to the deleted path, causing every hook invocation to fail.

Steps to reproduce

  1. Start a Claude Code session (session A)
  2. Start a second session (session B) — this triggers plugin auto-update if upstream changed
  3. Return to session A and use any tool
  4. Every hookify hook fails: Plugin directory does not exist: .../hookify/<old_hash>

Impact

  • Affects any plugin that registers hooks (hookify is the primary one)
  • Error fires on every PreToolUse, PostToolUse, and Stop event — dozens of errors per conversation
  • Non-blocking but very noisy, and the error message tells users to reinstall when the plugin is already current

Observed behavior

Plugin cache hashes observed changing multiple times in a single day:

  • 03804b3b2735 -> a7a83f99ce07 -> 150430d80202

Each transition broke all running sessions referencing the previous hash.

Suggested fixes

  1. Keep old cache dirs for a grace period (e.g. 24h) instead of deleting immediately
  2. Re-resolve ${CLAUDE_PLUGIN_ROOT} on each hook invocation rather than caching at session start
  3. Symlink old -> new during update (this is my current workaround via a SessionStart hook)

Workaround

Created a SessionStart hook that records plugin hashes to a history file and creates symlinks from old hashes to the current version:

ln -s <new_hash> ~/.claude/plugins/cache/claude-plugins-official/hookify/<old_hash>

Environment

  • Claude Code 2.1.104
  • macOS Darwin 23.4.0
  • hookify@claude-plugins-official

extent analysis

TL;DR

Implement a solution to update the ${CLAUDE_PLUGIN_ROOT} path for running sessions after a plugin auto-update, such as re-resolving the path on each hook invocation or keeping old cache directories for a grace period.

Guidance

  • Re-resolve ${CLAUDE_PLUGIN_ROOT} on each hook invocation instead of caching it at session start to ensure the latest plugin directory is used.
  • Consider keeping old cache directories for a limited time (e.g., 24 hours) to allow running sessions to continue functioning without interruption.
  • Implement a mechanism to update the ${CLAUDE_PLUGIN_ROOT} path for running sessions after a plugin auto-update, such as using symlinks to point to the new plugin directory.
  • Verify that the chosen solution works by testing it with multiple sessions and plugin updates.

Example

The provided workaround using a SessionStart hook to create symlinks from old hashes to the current version can be used as a temporary solution:

ln -s <new_hash> ~/.claude/plugins/cache/claude-plugins-official/hookify/<old_hash>

Notes

The solution should be tested thoroughly to ensure it works correctly with different plugin updates and session scenarios. Additionally, the chosen approach may have performance implications that should be considered.

Recommendation

Apply a workaround, such as re-resolving ${CLAUDE_PLUGIN_ROOT} on each hook invocation or keeping old cache directories for a limited time, as it provides a more immediate solution to the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING