zeroclaw-labs/zeroclaw · error

memory backend 'postgres' requested but this build was compi

Error message

memory backend 'postgres' requested but this build was compiled without `memory-postgres`; rebuild with `--features memory-postgres`

What it means

The memory factory selected the PostgreSQL backend, but the zeroclaw-memory crate was compiled without the optional `memory-postgres` Cargo feature. In feature-less builds, build_postgres_memory is a stub whose only job is to fail with this message. PostgreSQL support is compile-time optional so the postgres client dependency stays out of default builds.

Source

Thrown at crates/zeroclaw-memory/src/lib.rs:110

    use postgres::PostgresMemory;
    let db_url = storage
        .db_url
        .as_deref()
        .context("memory backend 'postgres' requires [storage.postgres.<alias>].db_url")?;
    PostgresMemory::new(
        "postgres",
        db_url,
        &storage.schema,
        &storage.table,
        storage.connect_timeout_secs,
        Some(storage.vector_enabled),
        Some(storage.vector_dimensions),
    )
}

#[cfg(not(feature = "memory-postgres"))]
fn build_postgres_memory(_storage: &PostgresStorageConfig) -> anyhow::Result<Box<dyn Memory>> {
    anyhow::bail!(
        "memory backend 'postgres' requested but this build was compiled without \
         `memory-postgres`; rebuild with `--features memory-postgres`"
    )
}

/// Wrap the backend in the `AuditedMemory` decorator when
/// `[memory] audit_enabled = true`; pass it through untouched otherwise
/// (the default), so the flag-off path is byte-identical to an unwrapped
/// backend.
fn wrap_audit<M: Memory + 'static>(
    memory: M,
    workspace_dir: &Path,
    audit_enabled: bool,
) -> anyhow::Result<Box<dyn Memory>> {
    if audit_enabled {
        Ok(Box::new(AuditedMemory::new(memory, workspace_dir)?))
    } else {
        Ok(Box::new(memory))

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. Rebuild with the feature enabled: `cargo build --features memory-postgres` (or enable the workspace/bin feature that forwards to zeroclaw-memory's memory-postgres).
  2. If PostgreSQL is not required, switch the config to a backend that ships by default: `memory.backend = "sqlite"`, `"lucid"`, `"markdown"`, or `"qdrant"`.
  3. Verify the artifact actually has the feature before deploying, e.g. `cargo tree -e features -i tokio-postgres` against the build recipe.

Example fix

# before
# build: cargo build
[memory]
backend = "postgres.main"

# after
# build: cargo build --features memory-postgres
[memory]
backend = "postgres.main"
Defensive patterns

Strategy: validation

Validate before calling

// In the binary/service crate, fail fast at startup instead of first memory use
#[cfg(not(feature = "memory-postgres"))]
if config.memory.backend.split('.').next() == Some("postgres") {
    anyhow::bail!(
        "config selects the postgres memory backend but this build lacks `memory-postgres`; \
         rebuild with --features memory-postgres or change memory.backend"
    );
}

Try / catch

let memory = match create_memory_from_config(&config, api_key) {
    Ok(m) => m,
    Err(e) if e.to_string().contains("memory-postgres") => {
        // operator-actionable: rebuild the binary or switch memory.backend
        return Err(e.context("postgres backend selected in a build without memory-postgres"));
    }
    Err(e) => return Err(e),
};

Prevention

When it happens

Trigger: Setting `memory.backend = "postgres"` (or `"postgres.<alias>"`) in the active config and constructing memory via create_memory, create_memory_from_config, or create_memory_with_storage_and_routes on a binary built with default features. The postgres branch resolves the [storage.postgres.<alias>] entry, then hits the cfg(not(feature))-gated stub.

Common situations: Running a distribution or plain `cargo build` artifact against a config written for a feature-enabled deployment; CI building without `--features memory-postgres`; assuming the postgres client dependency ships by default; upgrading a deployment where the new build recipe dropped the feature.

Related errors


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/95b24b84b66da56f. Report an issue: GitHub.