paperclipai/paperclip · error · Error
Could not resolve worktree "${selector}". Use a path, a list
Error message
Could not resolve worktree "${selector}". Use a path, a listed worktree directory name, branch name, or "current". What it means
Thrown by resolveWorktreeEndpointFromSelector when the selector is non-empty, does NOT resolve to an existing path, and does not match any listed worktree by worktree dir, directory basename, or branch label. The resolver checks `git worktree list`-derived choices (toMergeSourceChoices) and falls back to this error when nothing matches. The message lists the accepted selector shapes.
Source
Thrown at cli/src/commands/worktree.ts:2860
if (!existsSync(configPath)) {
throw new Error(`Resolved worktree path ${directPath} does not contain .paperclip/config.json.`);
}
return {
rootPath: directPath,
configPath,
label: path.basename(directPath),
isCurrent: false,
};
}
const matched = choices.find((choice) =>
(allowCurrent || !choice.isCurrent)
&& (choice.worktree === directPath
|| path.basename(choice.worktree) === trimmed
|| choice.branchLabel === trimmed),
);
if (!matched) {
throw new Error(
`Could not resolve worktree "${selector}". Use a path, a listed worktree directory name, branch name, or "current".`,
);
}
if (!matched.hasPaperclipConfig && !matched.isCurrent) {
throw new Error(`Resolved worktree "${selector}" does not look like a Paperclip worktree.`);
}
return resolveEndpointFromChoice(matched);
}
async function promptForSourceEndpoint(excludeWorktreePath?: string): Promise<ResolvedWorktreeEndpoint> {
const excluded = excludeWorktreePath ? path.resolve(excludeWorktreePath) : null;
const currentEndpoint = resolveCurrentWorktreeEndpoint();
const choices = toMergeSourceChoices(process.cwd())
.filter((choice) => choice.hasPaperclipConfig || choice.isCurrent)
.filter((choice) => path.resolve(choice.worktree) !== excluded)
.map((choice) => ({
value: choice.isCurrent ? "__current__" : choice.worktree,
label: choice.branchLabel,View on GitHub (pinned to 67001ec6eb)
Solutions
- List valid worktrees: `paperclipai worktree:list` and use one of the shown directories/branches.
- Use 'current' to target the worktree you're inside.
- Check for typos and that the path/branch actually exists in this repo.
- If the worktree was removed, recreate it (`worktree:make`) before referencing it.
Example fix
// before paperclipai worktree:merge-history --source feat-xyz # no such worktree // after paperclipai worktree:list # see valid names paperclipai worktree:merge-history --source feat-x
Defensive patterns
Strategy: validation
Validate before calling
const choices = toMergeSourceChoices(process.cwd());
const ok = existsSync(path.resolve(selector))
|| choices.some((c) => c.worktree === path.resolve(selector) || path.basename(c.worktree) === selector || c.branchLabel === selector);
if (!ok) throw new Error(`Selector '${selector}' matches no worktree; see worktree:list`); Type guard
function selectorResolvable(selector: string, choices: MergeSourceChoice[]): boolean {
const d = path.resolve(selector);
return existsSync(d) || choices.some((c) => c.worktree === d || path.basename(c.worktree) === selector || c.branchLabel === selector);
} Prevention
- Run `worktree:list` and copy a valid directory/branch from its output.
- Use 'current' when operating inside a worktree.
- Double-check branch/path names for typos.
When it happens
Trigger: Typo in a branch name or directory name; referencing a worktree that was already removed/cleaned; selector is a path that doesn't exist; branch name from a different repository.
Common situations: Stale memory of a worktree name; cleaned worktree still referenced by an old command; cross-repo branch name confusion.
Related errors
- Branch name is required.
- Invalid branch name "${branchName}": ${extractExecSyncErrorM
- Unsupported seed mode "${seedMode}". Expected one of: minima
- Worktree config already exists at ${paths.configPath} or ins
- Target path already exists: ${targetPath}
AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12).
Data as JSON: /api/errors/eecc8c7f4cf5fbf6.
Report an issue: GitHub.