CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILURE breaks fresh marketplace installation
Summary
Setting CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILURE=1 in settings.json causes all new marketplace installations to fail with "Marketplace file not found", because it prevents the initial clone from ever running.
Steps to Reproduce
- Add
"CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILURE": "1"to theenvblock in~/.claude/settings.json - Run
/installand enter any new marketplace (e.g.JuliusBrussee/caveman) - Observe immediate error:
Marketplace file not found at ~/.claude/plugins/marketplaces/JuliusBrussee-caveman/.claude-plugin/marketplace.json
No clone progress is shown. The directory is never created.
Root Cause
Traced from the 2.1.92 binary. The Ws function serves double duty as both a fresh clone path and a refresh/update path for existing marketplaces. On a fresh install:
Dt9(sparse-checkout reconcile) returns{code: 0}when the directory doesn't exist. When nosparsePathsare configured, it runsgit config --get core.sparseCheckoutin the target directory. This git command fails (non-zero exit) because the directory doesn't exist — butDt9only returns{code: 1}when the command succeeds and reportstrue. A git failure falls through toreturn {code: 0, stderr: ""}— falsely signaling "no sparse checkout issues."
Yt9(git pull) is then attempted on the non-existent directory and fails immediately.
KEEP_MARKETPLACE_ON_FAILUREcauses early return without cloning:
``jsgit pull failed, keeping existing clone...
if (dH(process.env.CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILURE)) {
N();``
return; // ← exits without ever cloning
}
The function can't distinguish "pull failed on an existing clone" from "directory doesn't exist yet."
- Back in
D66, no error was thrown, so it tries to read.claude-plugin/marketplace.jsonfrom the never-created directory → "Marketplace file not found".
Expected Behavior
CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILURE should only apply when a marketplace directory already exists. For fresh installs (directory absent), the clone should always proceed regardless of this env var.
Suggested Fix
In Ws, before applying the KEEP_MARKETPLACE_ON_FAILURE guard, check whether the target directory actually exists:
if (dH(process.env.CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILURE) && directoryExists($)) {
// keep existing clone
return;
}
// fall through to re-clone
Alternatively, Dt9 could return {code: 1} when the target directory doesn't exist at all, which would bypass the git pull path entirely and go straight to clone.
Environment
- Version: 2.1.92
- Platform: Linux (WSL2)
- Workaround: Remove
CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILUREfromsettings.jsonenv block
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗