-
Notifications
You must be signed in to change notification settings - Fork 185
Description
Problem
hindsight-embed daemon_client.py hardcodes HINDSIGHT_API_DATABASE_URL to pg0://hindsight-embed on line 79, overriding any value already set in the environment:
env["HINDSIGHT_API_DATABASE_URL"] = "pg0://hindsight-embed"This means users running on a VPS as root (common setup for OpenClaw, Docker-less deployments) cannot use an external PostgreSQL instance to work around the initdb: error: cannot be run as root limitation of embedded pg0.
Environment
- hindsight-embed v0.4.6
- Hetzner VPS (Ubuntu 24.04, running as root)
- OpenClaw with hindsight-openclaw plugin
Error
RuntimeError: Failed to start embedded PostgreSQL after 5 attempts.
Last error: Error: PostgreSQL error: Command error:
stdout=; stderr=initdb: error: cannot be run as root
initdb: hint: Please log in (using, e.g., "su") as the (unprivileged) user that will own the server process.
Root Cause
hindsight-api properly supports external PostgreSQL via HINDSIGHT_API_DATABASE_URL (e.g. postgresql://user:pass@localhost:5432/hindsight). However, hindsight-embed/daemon_client.py unconditionally overwrites this env var before spawning the daemon, making it impossible to use external PostgreSQL.
Workaround
We patched daemon_client.py line 79 to respect existing env vars:
# Before (broken for root users):
env["HINDSIGHT_API_DATABASE_URL"] = "pg0://hindsight-embed"
# After (respects user override):
if "HINDSIGHT_API_DATABASE_URL" not in env:
env["HINDSIGHT_API_DATABASE_URL"] = "pg0://hindsight-embed"Combined with installing PostgreSQL 16 as a system service with pgvector extension, Hindsight works perfectly on a root VPS.
Suggested Fix
One-line change in hindsight-embed/hindsight_embed/daemon_client.py:
if "HINDSIGHT_API_DATABASE_URL" not in env:
env["HINDSIGHT_API_DATABASE_URL"] = "pg0://hindsight-embed"This preserves the default behavior (pg0 embedded) while allowing users who set HINDSIGHT_API_DATABASE_URL to use an external PostgreSQL instance.
Who This Affects
- Anyone running OpenClaw/hindsight-embed on a VPS as root (common for Hetzner, DigitalOcean, etc.)
- Anyone wanting to use an external PostgreSQL for better control over the database
- Docker users are unaffected (Docker image runs as non-root
hindsightuser)