claude-code - 💡(How to fix) Fix [BUG] Plugin marketplace removal leaves orphaned cache and data directories [1 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#47077Fetched 2026-04-13 05:42:06
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
labeled ×2

Error Message

Error Messages/Logs

No error messages — the removal completes silently without cleaning up the filesystem.

Fix Action

Fix / Workaround

Manual workaround

Code Example

~/.claude/plugins/cache/draft-plugins/     4.0M  (marketplace removed, cache remained)
~/.claude/plugins/cache/mayurpise-codev/   6.5M  (marketplace removed, cache remained)

---

/plugin  -->  Add marketplace  -->  provide repo URL

---

ls ~/.claude/plugins/cache/    # shows <marketplace-name>/ directory
   ls ~/.claude/plugins/data/     # may show <plugin>-<marketplace>/ directory

---

ls ~/.claude/plugins/cache/    # <marketplace-name>/ still exists (BUG)
   ls ~/.claude/plugins/data/     # <plugin>-<marketplace>/ still exists (BUG)
   cat ~/.claude/plugins/known_marketplaces.json   # marketplace entry correctly removed
   cat ~/.claude/plugins/installed_plugins.json    # plugin entries may still reference it

---

// Pseudocode for marketplace removal cleanup
async function removeMarketplace(marketplaceName: string) {
  // 1. Remove from known_marketplaces.json (already implemented)
  await removeFromKnownMarketplaces(marketplaceName);

  // 2. Remove all plugins from this marketplace in installed_plugins.json
  const installedPlugins = await readInstalledPlugins();
  for (const [key, entries] of Object.entries(installedPlugins.plugins)) {
    if (key.endsWith(`@${marketplaceName}`)) {
      delete installedPlugins.plugins[key];
    }
  }
  await writeInstalledPlugins(installedPlugins);

  // 3. Delete cached plugin builds
  const cachePath = path.join(pluginsDir, 'cache', marketplaceName);
  await fs.rm(cachePath, { recursive: true, force: true });

  // 4. Delete plugin runtime data
  const dataDir = path.join(pluginsDir, 'data');
  const dataEntries = await fs.readdir(dataDir);
  for (const entry of dataEntries) {
    if (entry.endsWith(`-${marketplaceName}`)) {
      await fs.rm(path.join(dataDir, entry), { recursive: true, force: true });
    }
  }
}

---

async function uninstallPlugin(pluginName: string, marketplaceName: string) {
  // 1. Remove from installed_plugins.json (already implemented)

  // 2. Delete plugin cache
  const cachePath = path.join(pluginsDir, 'cache', marketplaceName, pluginName);
  await fs.rm(cachePath, { recursive: true, force: true });

  // 3. Delete plugin data
  const dataPath = path.join(pluginsDir, 'data', `${pluginName}-${marketplaceName}`);
  await fs.rm(dataPath, { recursive: true, force: true });
}

---

~/.claude/plugins/
  blocklist.json
  install-counts-cache.json
  installed_plugins.json          # no references to removed marketplaces
  known_marketplaces.json         # only lists "claude-code-plugins"
  cache/
    claude-code-plugins/          # active — has installed plugins
    draft-plugins/                # ORPHANED — marketplace was removed
    mayurpise-codev/              # ORPHANED — marketplace was removed
  data/
    explanatory-output-style-claude-code-plugins/   # active
  marketplaces/
    claude-code-plugins/          # active marketplace repo clone

---

# Identify orphaned caches by comparing against known_marketplaces.json
rm -rf ~/.claude/plugins/cache/<removed-marketplace-name>/
rm -rf ~/.claude/plugins/data/*-<removed-marketplace-name>/
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report
  • I am using the latest version of Claude Code

What's Wrong?

When removing a plugin marketplace via /plugin, the marketplace entry is correctly deleted from ~/.claude/plugins/known_marketplaces.json, but the corresponding cache and data directories are left behind on disk.

This means:

  1. ~/.claude/plugins/cache/<marketplace-name>/ persists with all downloaded plugin builds
  2. ~/.claude/plugins/data/<plugin-name>-<marketplace-name>/ persists with any runtime data
  3. Users accumulate orphaned directories over time with no built-in way to clean them

In my case, removing two third-party marketplaces left ~10.5 MB of orphaned cache:

~/.claude/plugins/cache/draft-plugins/     4.0M  (marketplace removed, cache remained)
~/.claude/plugins/cache/mayurpise-codev/   6.5M  (marketplace removed, cache remained)

The installed_plugins.json no longer references these marketplaces, and known_marketplaces.json only lists the official claude-code-plugins — yet the cache directories persist.

What Should Happen?

When a marketplace is removed via /plugin:

  1. All cached plugin builds under ~/.claude/plugins/cache/<marketplace-name>/ should be deleted
  2. All plugin data under ~/.claude/plugins/data/*-<marketplace-name>/ should be deleted
  3. Any plugin entries in installed_plugins.json referencing that marketplace should be removed

Similarly, when an individual plugin is uninstalled:

  1. Its cache directory (~/.claude/plugins/cache/<marketplace>/<plugin>/) should be deleted
  2. Its data directory (~/.claude/plugins/data/<plugin>-<marketplace>/) should be deleted
  3. Its entry in installed_plugins.json should be removed (this part already works)

Steps to Reproduce

  1. Install a third-party marketplace:
    /plugin  -->  Add marketplace  -->  provide repo URL
  2. Install a plugin from that marketplace
  3. Verify cache exists:
    ls ~/.claude/plugins/cache/    # shows <marketplace-name>/ directory
    ls ~/.claude/plugins/data/     # may show <plugin>-<marketplace>/ directory
  4. Remove the marketplace via /plugin → Remove marketplace
  5. Check again:
    ls ~/.claude/plugins/cache/    # <marketplace-name>/ still exists (BUG)
    ls ~/.claude/plugins/data/     # <plugin>-<marketplace>/ still exists (BUG)
    cat ~/.claude/plugins/known_marketplaces.json   # marketplace entry correctly removed
    cat ~/.claude/plugins/installed_plugins.json    # plugin entries may still reference it

Error Messages/Logs

No error messages — the removal completes silently without cleaning up the filesystem.

Proposed Fix

The marketplace-remove and plugin-uninstall handlers in the CLI should:

// Pseudocode for marketplace removal cleanup
async function removeMarketplace(marketplaceName: string) {
  // 1. Remove from known_marketplaces.json (already implemented)
  await removeFromKnownMarketplaces(marketplaceName);

  // 2. Remove all plugins from this marketplace in installed_plugins.json
  const installedPlugins = await readInstalledPlugins();
  for (const [key, entries] of Object.entries(installedPlugins.plugins)) {
    if (key.endsWith(`@${marketplaceName}`)) {
      delete installedPlugins.plugins[key];
    }
  }
  await writeInstalledPlugins(installedPlugins);

  // 3. Delete cached plugin builds
  const cachePath = path.join(pluginsDir, 'cache', marketplaceName);
  await fs.rm(cachePath, { recursive: true, force: true });

  // 4. Delete plugin runtime data
  const dataDir = path.join(pluginsDir, 'data');
  const dataEntries = await fs.readdir(dataDir);
  for (const entry of dataEntries) {
    if (entry.endsWith(`-${marketplaceName}`)) {
      await fs.rm(path.join(dataDir, entry), { recursive: true, force: true });
    }
  }
}

Similarly for individual plugin uninstall:

async function uninstallPlugin(pluginName: string, marketplaceName: string) {
  // 1. Remove from installed_plugins.json (already implemented)

  // 2. Delete plugin cache
  const cachePath = path.join(pluginsDir, 'cache', marketplaceName, pluginName);
  await fs.rm(cachePath, { recursive: true, force: true });

  // 3. Delete plugin data
  const dataPath = path.join(pluginsDir, 'data', `${pluginName}-${marketplaceName}`);
  await fs.rm(dataPath, { recursive: true, force: true });
}

Environment

  • Claude Code Version: 2.1.104
  • Platform: Anthropic API
  • OS: Ubuntu Linux (6.17.0-1014-nvidia, ARM64)
  • Terminal: VS Code integrated terminal
  • Model: Opus 4.6
  • Is this a regression?: I don't know

Additional Information

Directory structure after marketplace removal (showing the bug)

~/.claude/plugins/
  blocklist.json
  install-counts-cache.json
  installed_plugins.json          # no references to removed marketplaces
  known_marketplaces.json         # only lists "claude-code-plugins"
  cache/
    claude-code-plugins/          # active — has installed plugins
    draft-plugins/                # ORPHANED — marketplace was removed
    mayurpise-codev/              # ORPHANED — marketplace was removed
  data/
    explanatory-output-style-claude-code-plugins/   # active
  marketplaces/
    claude-code-plugins/          # active marketplace repo clone

Manual workaround

Users can manually clean orphaned directories:

# Identify orphaned caches by comparing against known_marketplaces.json
rm -rf ~/.claude/plugins/cache/<removed-marketplace-name>/
rm -rf ~/.claude/plugins/data/*-<removed-marketplace-name>/

extent analysis

TL;DR

The proposed fix involves modifying the marketplace removal and plugin uninstall handlers to delete orphaned cache and data directories.

Guidance

  • Implement the removeMarketplace function as described in the proposed fix to clean up cache and data directories when a marketplace is removed.
  • Implement the uninstallPlugin function to delete plugin cache and data when an individual plugin is uninstalled.
  • Verify that the installed_plugins.json file is updated correctly after marketplace removal or plugin uninstall.
  • Test the changes by removing a marketplace and verifying that the corresponding cache and data directories are deleted.

Example

The provided pseudocode for removeMarketplace and uninstallPlugin functions can be used as a starting point for implementing the fix.

Notes

The fix assumes that the fs module is available for file system operations. Additionally, the path module is used for constructing file paths.

Recommendation

Apply the proposed workaround by implementing the removeMarketplace and uninstallPlugin functions as described, to ensure that orphaned cache and data directories are cleaned up when a marketplace is removed or a plugin is uninstalled. This will help maintain a clean file system and prevent accumulation of unnecessary data.

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