Plugin install fails with malformed marketplace path after marketplace remove/re-add in same session
Environment
- Claude Code version: 2.1.220
- Platform: macOS (Darwin 25.5.0)
- Shell: zsh
Description
After removing and re-adding a plugin marketplace within the same interactive session, /plugin install fails from the plugin selection menu with a malformed path error:
Marketplace file not found at /Users/mcneill/.claude/plugins/marketplaces/epik-agent-Epik/Users/mcneill/Projects/Epik/Epik
The path is the sanitized marketplace source string (epik-agent/Epik → epik-agent-Epik) joined with the current project directory (/Users/mcneill/Projects/Epik/Epik) — i.e. something like path.join(marketplacesDir, sanitizedSource, cwd). Neither component matches the actual install location.
Steps to reproduce
Inside an interactive session whose working directory is the marketplace's own source repo (which contains .claude-plugin/marketplace.json):
/plugin marketplace update epik(marketplace previously registered from GitHub repoepik-agent/Epik)/plugin marketplace remove epik/plugin marketplace add epik-agent/Epik— succeeds, clones to~/.claude/plugins/marketplaces/epik/plugin install epik@epikfrom the selection menu — fails with the error above
Expected behavior
The install should read the marketplace from its registered installLocation (~/.claude/plugins/marketplaces/epik), which is exactly what happens outside the session.
Evidence that on-disk state was healthy
~/.claude/plugins/known_marketplaces.jsonhad the correct entry: sourcegithub: epik-agent/Epik, installLocation~/.claude/plugins/marketplaces/epik- That clone existed, was on the current head commit, and its
.claude-plugin/marketplace.jsonwas valid (plugin source./plugin, relative) - The malformed path (
epik-agent-Epik+ project dir) appeared in no config file — only in session history, so it was computed at runtime from stale in-session state - Running
claude plugin install epik@epikfrom a fresh CLI process succeeded immediately with no changes to any files
Suspected cause
Stale in-memory marketplace state after a remove/re-add cycle in the same session, with the path computed from the sanitized source argument and the session cwd instead of the registered installLocation. Possibly aggravated by the cwd itself being a marketplace source repo.