{"record":{"id":"270bab93fd92a129","repo":"paperclipai/paperclip","slug":"embedded-postgresql-support-requires-dependency-e-270bab","errorCode":null,"errorMessage":"Embedded PostgreSQL support requires dependency `embedded-postgres`. Reinstall dependencies and try again.","messagePattern":"Embedded PostgreSQL support requires dependency `embedded-postgres`\\. Reinstall dependencies and try again\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":1094,"sourceCode":"    );\n  }\n\n  copyFileSync(sourceKeyFilePath, input.targetKeyFilePath);\n  try {\n    chmodSync(input.targetKeyFilePath, 0o600);\n  } catch {\n    // best effort\n  }\n}\n\nasync function ensureEmbeddedPostgres(dataDir: string, preferredPort: number): Promise<EmbeddedPostgresHandle> {\n  const moduleName = \"embedded-postgres\";\n  let EmbeddedPostgres: EmbeddedPostgresCtor;\n  try {\n    const mod = await import(moduleName);\n    EmbeddedPostgres = mod.default as EmbeddedPostgresCtor;\n  } catch {\n    throw new Error(\n      \"Embedded PostgreSQL support requires dependency `embedded-postgres`. Reinstall dependencies and try again.\",\n    );\n  }\n  await prepareEmbeddedPostgresNativeRuntime();\n\n  const postmasterPidFile = path.resolve(dataDir, \"postmaster.pid\");\n  const runningPid = readRunningPostmasterPid(postmasterPidFile);\n  if (runningPid) {\n    return {\n      port: readPidFilePort(postmasterPidFile) ?? preferredPort,\n      startedByThisProcess: false,\n      stop: async () => {},\n    };\n  }\n\n  const port = await findAvailablePort(preferredPort);\n  const logBuffer = createEmbeddedPostgresLogBuffer();\n  const instance = new EmbeddedPostgres({","sourceCodeStart":1076,"sourceCodeEnd":1112,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/worktree.ts#L1076-L1112","documentation":"Thrown by ensureEmbeddedPostgres when the dynamic import('embedded-postgres') fails. The worktree reseed needs embedded-postgres to run a local postgres instance for the dump/restore; without the native dependency it cannot proceed.","triggerScenarios":"embedded-postgres not installed in the CLI package's node_modules; install was partial/failed; the package is an optionalDependency that was skipped on this platform; native runtime (prepareEmbeddedPostgresNativeRuntime) prerequisites missing so the import throws.","commonSituations":"Fresh checkout without pnpm install; partial install on a platform where embedded-postgres native binaries were skipped; monorepo hoisting left embedded-postgres inaccessible to the cli package; Node version incompatibility breaking the native addon.","solutions":["Run `pnpm install` (or the repo's install command) to ensure embedded-postgres is installed.","Confirm the package resolves from the cli workspace: `pnpm why embedded-postgres` / `ls node_modules/embedded-postgres`.","Verify your platform/arch has supported native binaries; if not, run on a supported platform or use external postgres mode.","Ensure prepareEmbeddedPostgresNativeRuntime's prerequisites (toolchain/libc) are present."],"exampleFix":"# before: missing dep\n# after\npnpm install && pnpm --filter @paperclipai/cli rebuild","handlingStrategy":"fallback","validationCode":"async function embeddedPostgresAvailable(): Promise<boolean> {\n  try { await import('embedded-postgres'); return true; } catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await ensureEmbeddedPostgres(dataDir, port);\n} catch (e) {\n  if (/embedded-postgres/.test((e as Error).message)) {\n    console.error('Run `pnpm install` to install embedded-postgres, or use external postgres mode.');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Run the repo install command after every checkout.","Verify embedded-postgres resolves from the cli workspace.","On unsupported platforms, run external postgres mode instead."],"tags":["database","embedded-postgres","dependency","install","native"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}