paperclipai/paperclip · error · Error
Target worktree database appears to be running (pid ${runnin
Error message
Target worktree database appears to be running (pid ${runningTargetPid}). Stop Paperclip in ${targetEndpoint.rootPath} before reseeding, or re-run with --allow-live-target if you want to override this guard. What it means
Thrown by runWorktreeReseed when resolveRunningEmbeddedPostgresPid(targetConfig) returns a live pid and --allow-live-target is not set. resolveRunningEmbeddedPostgresPid only applies to embedded-postgres mode targets and reads postmaster.pid, and readRunningPostmasterPid additionally verifies liveness via process.kill(pid, 0). The guard prevents overwriting a running database, which could corrupt data or fail mid-copy. --allow-live-target is the documented escape hatch.
Source
Thrown at cli/src/commands/worktree.ts:3431
throw new Error(`Source config not found at ${source.configPath}.`);
}
const targetConfig = readConfig(targetEndpoint.configPath);
if (!targetConfig) {
throw new Error(`Target config not found at ${targetEndpoint.configPath}.`);
}
const sourceConfig = readConfig(source.configPath);
if (!sourceConfig) {
throw new Error(`Source config not found at ${source.configPath}.`);
}
const targetPaths = resolveWorktreeReseedTargetPaths({
configPath: targetEndpoint.configPath,
rootPath: targetEndpoint.rootPath,
});
const runningTargetPid = resolveRunningEmbeddedPostgresPid(targetConfig);
if (runningTargetPid && !opts.allowLiveTarget) {
throw new Error(
`Target worktree database appears to be running (pid ${runningTargetPid}). Stop Paperclip in ${targetEndpoint.rootPath} before reseeding, or re-run with --allow-live-target if you want to override this guard.`,
);
}
const confirmed = opts.yes
? true
: await p.confirm({
message: `Overwrite the isolated Paperclip DB for ${targetEndpoint.label} from ${source.label} using ${seedMode} seed mode?`,
initialValue: false,
});
if (p.isCancel(confirmed) || !confirmed) {
p.log.warn("Reseed cancelled.");
return;
}
if (runningTargetPid && opts.allowLiveTarget) {
p.log.warning(`Proceeding even though the target embedded PostgreSQL appears to be running (pid ${runningTargetPid}).`);
}View on GitHub (pinned to 67001ec6eb)
Solutions
- Stop Paperclip in the target worktree (e.g. stop the dev server / agent runtime) and retry.
- Re-run with --allow-live-target if you accept the risk of overwriting a live DB.
- Check for the live pid with `ps -p <pid>` to confirm which process holds it before deciding.
Example fix
// before paperclipai worktree reseed --from-config src.json --to /path/to/target // after (stop the target first) # in target worktree: stop paperclipai dev, then paperclipai worktree reseed --from-config src.json --to /path/to/target // or override the guard paperclipai worktree reseed --from-config src.json --to /path/to/target --allow-live-target
Defensive patterns
Strategy: validation
Validate before calling
import fs from "node:fs";
import path from "node:path";
function readLivePostmasterPid(dataDir: string): number | null {
const pidFile = path.resolve(dataDir, "postmaster.pid");
if (!fs.existsSync(pidFile)) return null;
const pid = Number(fs.readFileSync(pidFile, "utf8").split("\n")[0]?.trim());
if (!Number.isInteger(pid) || pid <= 0) return null;
try { process.kill(pid, 0); return pid; } catch { return null; }
}
// before reseed, read targetConfig.database.embeddedPostgresDataDir and check:
const livePid = readLivePostmasterPid(targetConfig.database.embeddedPostgresDataDir);
if (livePid && !opts.allowLiveTarget) {
throw new Error(`Stop the target embedded PostgreSQL (pid ${livePid}) before reseeding, or pass --allow-live-target.`);
} Prevention
- Stop `paperclipai dev` and any agent runtime in the target worktree before reseeding.
- Script a pre-check using readRunningPostmasterPid semantics (pid alive via process.kill(pid,0)) before invoking reseed.
- Use --allow-live-target only when you understand the data-loss risk.
When it happens
Trigger: Calling `worktree reseed` against a target worktree whose embedded PostgreSQL is currently running (the Paperclip server in that worktree is up), without --allow-live-target. The pid in postmaster.pid must belong to a live process.
Common situations: A developer left `paperclipai dev` (or a server) running in the target worktree and tries to reseed it from another terminal. Or a background agent runtime holds the embedded DB open.
Related errors
- Target worktree database appears to be running (pid ${runnin
- Source and target Paperclip configs are the same. Choose dif
- Source config not found at ${source.configPath}.
- Target config not found at ${targetEndpoint.configPath}.
- Use either --from <worktree> or --from-config/--from-data-di
AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12).
Data as JSON: /api/errors/d4a7f6a673add312.
Report an issue: GitHub.