[BUG] Plugin cache still creates duplicate SHA-named dirs when ~/.claude is a git repo (2.1.217) — #41043 was stale-closed, not fixed

Status Open
Reported on v2.1.217
Maintainer reply None cached
Activity 1 comment · opened Jul 22, 2026

Preflight Checklist

  • [x] I have searched existing issues — #41043 reported this exact bug, but it was closed as not_planned by the stale bot on 2026-05-22 without a fix. This report confirms it still reproduces on 2.1.217 with additional evidence.
  • [x] This is a single bug report
  • [x] I am using the latest version of Claude Code

Environment

  • Claude Code 2.1.217, Windows 11 Pro (10.0.26200)
  • ~/.claude is itself a git repository (dotfiles/config management), plugins/ is gitignored

What's Wrong?

Same root cause as #41043: when ~/.claude is a git repo, the plugin version computation for the official marketplace resolves to the user's config repo HEAD instead of the marketplace version, creating a duplicate SHA-named cache directory for every commit the user makes to their config repo.

Verified mechanism on 2.1.217:

  1. ~/.claude/plugins/marketplaces/claude-plugins-official/ is a GCS snapshot — it contains a .gcs-sha file (real marketplace SHA, e.g. 20a5a1f1a2b55b13e85dff5416613a796d089016) but no .git directory.
  2. Version detection appears to run git rev-parse HEAD in that directory. Since there is no local .git, git walks up the tree and finds ~/.claude/.git, returning the user's config repo HEAD. Running git rev-parse HEAD manually inside the marketplace directory reproduces this 1:1 — it returns the config repo's HEAD.
  3. Result: installed_plugins.json records version / gitCommitSha equal to the user's config repo commit SHA, and a new cache version directory named after that SHA is created under plugins/cache/claude-plugins-official/<plugin>/ on every marketplace refresh following a config repo commit.

Observed accumulation: 297 orphan version directories across 9 official plugins (33 versions each, directory names all verifiable as config repo commit SHAs via git cat-file -t), accumulated between 2026-07-11 and 2026-07-22.

Additional risk

Any write-mode git command the CLI runs in that marketplace directory (pull / checkout / clean / config) would operate on the user's ~/.claude repo instead. #65372 already demonstrated a marketplace auto-update rewriting .git/config of an unrelated repo — same failure class.

What Should Happen?

  1. When .gcs-sha exists, use it as the version key instead of falling through to git HEAD resolution.
  2. Any git invocation against a marketplace/cache path should be constrained (e.g. git -C <dir> --git-dir=<dir>/.git, or set GIT_CEILING_DIRECTORIES) so it can never walk up into an unrelated parent repository.
  3. Reopen consideration of #41043 — it was closed by the stale bot, not fixed.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗