[BUG] Marketplace add fails - cleanup deletes cloned directory before rename can complete

Resolved 💬 3 comments Opened Feb 4, 2026 by revmischa Closed Mar 5, 2026

Bug Description

When adding a marketplace with /plugin marketplace add METR/claude-code, the command fails with an ENOENT error during the rename step. The root cause is that the cleanup step deletes the freshly cloned directory before the rename can complete.

Steps to Reproduce

  1. Run /plugin marketplace add METR/claude-code (or any marketplace where the repo owner name is uppercase)
  2. Observe the error:

``
Failed to finalize marketplace cache. Please manually delete the directory at /Users/user/.claude/plugins/marketplaces/metr-claude-code if it exists and try again.
Technical details: ENOENT: no such file or directory, rename '/Users/user/.claude/plugins/marketplaces/METR-claude-code' -> '/Users/user/.claude/plugins/marketplaces/metr-claude-code'
``

Root Cause Analysis

I monitored the filesystem during the command execution and found:

  1. Clone step: Creates /Users/user/.claude/plugins/marketplaces/METR-claude-code (preserving the uppercase from the GitHub org name "METR")
  2. Validation step: Reads marketplace.json which has "name": "metr-claude-code" (lowercase)
  3. Cleanup step ("Cleaning up old marketplace cache…"): Deletes METR-claude-code because it doesn't match the expected final name
  4. Rename step: Tries to rename METR-claude-code to metr-claude-code, fails with ENOENT because the source was just deleted

The cleanup logic appears to delete any directory that doesn't match the expected final marketplace name, not realizing that METR-claude-code is the just-cloned source that needs to be renamed.

Filesystem Evidence

# During clone:
drwxr-xr-x - mish  4 Feb 15:33 METR-claude-code  # <-- Created

# After "Cleaning up old marketplace cache…":
(METR-claude-code is gone!)

# Then rename fails because source doesn't exist

Environment

  • OS: macOS (case-insensitive filesystem)
  • Claude Code Version: Latest

Workaround

Manually clone the marketplace repo:

git clone https://github.com/METR/claude-code.git ~/.claude/plugins/marketplaces/metr-claude-code

Suggested Fix

The cleanup logic should:

  1. Not delete the source directory before the rename, OR
  2. Perform the rename before the cleanup, OR
  3. Skip cleanup of directories that match the source pattern (original case from clone)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗