{"record":{"id":"e38702de24e81d42","repo":"thedotmack/claude-mem","slug":"skipping-local-hook-api-key-bootstrap-claude-mem","errorCode":null,"errorMessage":"Skipping local hook API key bootstrap: CLAUDE_MEM_SERVER_DATABASE_URL is not set. Run `npx claude-mem server keys rotate` after configuring Postgres to provision a key.","messagePattern":"Skipping local hook API key bootstrap: CLAUDE_MEM_SERVER_DATABASE_URL is not set\\. Run `npx claude-mem server keys rotate` after configuring Postgres to provision a key\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/npx-cli/commands/install.ts","lineNumber":1017,"sourceCode":"      + `(pg + redis/valkey). The server listens at ${serverBaseUrl}.`,\n  );\n\n  // The server mounts its MCP endpoint at `<baseUrl>/mcp` over HTTP (vs. the\n  // worker's stdio transport); trailing slashes are trimmed so we never emit\n  // `http://host//mcp`.\n  log.info(\n    `IDE MCP config target for the server runtime: http ${serverBaseUrl.replace(/\\/+$/, '')}/mcp`,\n  );\n\n  await maybeBootstrapServerApiKey();\n}\n\nasync function maybeBootstrapServerApiKey(): Promise<void> {\n  // Only attempt if Postgres is configured. Without DATABASE_URL we cannot\n  // reach the api_keys table — the operator must configure the server first\n  // and rerun `claude-mem server keys rotate`.\n  if (!process.env.CLAUDE_MEM_SERVER_DATABASE_URL) {\n    log.warn(\n      'Skipping local hook API key bootstrap: CLAUDE_MEM_SERVER_DATABASE_URL is not set. '\n        + 'Run `npx claude-mem server keys rotate` after configuring Postgres to provision a key.',\n    );\n    return;\n  }\n  try {\n    await bootstrapAndPersistServerApiKey();\n  } catch (error: unknown) {\n    // [ANTI-PATTERN IGNORED]: the failure is already surfaced to the user via the interactive-aware log.warn wrapper below (p.log.warn in a TTY, console.warn otherwise), including the manual remediation command.\n    log.warn(\n      `Failed to bootstrap server API key: ${error instanceof Error ? error.message : String(error)}. `\n        + 'Hooks will fall back to the worker until you run `npx claude-mem server keys rotate`.',\n    );\n  }\n}\n\nasync function bootstrapAndPersistServerApiKey(): Promise<void> {\n  const { bootstrapServerApiKey, persistServerSettings } = await import(","sourceCodeStart":999,"sourceCodeEnd":1035,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/npx-cli/commands/install.ts#L999-L1035","documentation":"During install, the optional local hook API key bootstrap only runs when Postgres is configured via CLAUDE_MEM_SERVER_DATABASE_URL. Without that env var the api_keys table is unreachable, so the installer skips bootstrapping and warns the operator to run `npx claude-mem server keys rotate` after configuring Postgres.","triggerScenarios":"Running the install command with `process.env.CLAUDE_MEM_SERVER_DATABASE_URL` unset — e.g. default installs that don't use the Postgres-backed server mode.","commonSituations":"Local-only installs using SQLite/file storage; env var set only in a shell profile not loaded by the npx process; users intending server mode but forgetting to export DATABASE_URL before install.","solutions":["If server mode is intended: set CLAUDE_MEM_SERVER_DATABASE_URL to your Postgres connection string, then rerun the installer.","After Postgres is configured, provision a key with `npx claude-mem server keys rotate` as the warning suggests.","If server mode is not intended, ignore the warning — hook API key bootstrap is optional."],"exampleFix":"// before\nnpx claude-mem install\n// after\nexport CLAUDE_MEM_SERVER_DATABASE_URL=postgres://user:pass@localhost:5432/claude_mem\nnpx claude-mem install","handlingStrategy":"validation","validationCode":"if (!process.env.CLAUDE_MEM_SERVER_DATABASE_URL) {\n  console.warn('Server API key bootstrap will be skipped; set CLAUDE_MEM_SERVER_DATABASE_URL first if you need server mode.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Export CLAUDE_MEM_SERVER_DATABASE_URL in the same shell/environment where you run `npx claude-mem install`.","Remember npx does not load your ~/.bashrc — set the env var explicitly per-invocation if needed.","After configuring Postgres, run `npx claude-mem server keys rotate` to provision the hook API key."],"tags":["environment","api-key","postgres","install"],"backgroundTag":"missing-env-var","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}