{"record":{"id":"5cfd9ee2f2b59c13","repo":"paperclipai/paperclip","slug":"reachable-postgres-does-not-use-the-expected-embed","errorCode":null,"errorMessage":"reachable postgres does not use the expected embedded data directory","messagePattern":"reachable postgres does not use the expected embedded data directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/db/src/migration-runtime.ts","lineNumber":112,"sourceCode":"): Promise<MigrationConnection> {\n  const EmbeddedPostgres = await loadEmbeddedPostgresCtor();\n  await prepareEmbeddedPostgresNativeRuntime();\n  const selectedPort = await findAvailablePort(preferredPort);\n  const postmasterPidFile = path.resolve(dataDir, \"postmaster.pid\");\n  const pgVersionFile = path.resolve(dataDir, \"PG_VERSION\");\n  const runningPid = readRunningPostmasterPid(postmasterPidFile);\n  const runningPort = readPidFilePort(postmasterPidFile);\n  const preferredAdminConnectionString = `postgres://paperclip:paperclip@127.0.0.1:${preferredPort}/postgres`;\n  const logBuffer = createEmbeddedPostgresLogBuffer();\n\n  if (!runningPid && existsSync(pgVersionFile)) {\n    try {\n      const actualDataDir = await getPostgresDataDirectory(preferredAdminConnectionString);\n      const matchesDataDir =\n        typeof actualDataDir === \"string\" &&\n        path.resolve(actualDataDir) === path.resolve(dataDir);\n      if (!matchesDataDir) {\n        throw new Error(\"reachable postgres does not use the expected embedded data directory\");\n      }\n      await ensurePostgresDatabase(preferredAdminConnectionString, \"paperclip\");\n      process.emitWarning(\n        `Adopting an existing PostgreSQL instance on port ${preferredPort} for embedded data dir ${dataDir} because postmaster.pid is missing.`,\n      );\n      return {\n        connectionString: `postgres://paperclip:paperclip@127.0.0.1:${preferredPort}/paperclip`,\n        source: `embedded-postgres@${preferredPort}`,\n        stop: async () => {},\n      };\n    } catch {\n      // Fall through and attempt to start the configured embedded cluster.\n    }\n  }\n\n  if (runningPid) {\n    const port = runningPort ?? preferredPort;\n    const adminConnectionString = `postgres://paperclip:paperclip@127.0.0.1:${port}/postgres`;","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/packages/db/src/migration-runtime.ts#L94-L130","documentation":"Error \"reachable postgres does not use the expected embedded data directory\" thrown in paperclipai/paperclip.","triggerScenarios":"Thrown at packages/db/src/migration-runtime.ts:112 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Point the app at the correct embedded data directory or remove the stale directory so a fresh embedded instance is initialized.","If another Postgres already uses that port, set DATABASE_URL to it explicitly."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}