jdx/mise · error

initdb and postgres have incompatible versions

Error message

initdb and postgres have incompatible versions

What it means

After creating a postgres data directory with initdb, mise reads the staged PG_VERSION file and compares it to the major version it parsed from `postgres --version`. If they differ, the initdb binary on PATH came from a different PostgreSQL major release than the postgres server binary, and mise refuses to commit the data directory because PG data is major-version specific. This guards against producing a data directory the server cannot open.

Solutions

  1. Ensure initdb and postgres come from the same installation: fix PATH so the same postgres prefix wins, or use mise's postgres shims for both.
  2. Run `which initdb` and `which postgres` (or `mise which postgres`) and compare their paths and major versions.
  3. If versions were recently changed, run `mise install`/`mise use` for the intended postgres version and reopen the shell so PATH refreshes.
  4. Delete any leftover staged data directory and retry initialization after aligning versions.

Example fix

// before (mismatched tools on PATH)
[tools]
postgres = "16"
# system initdb 15 still first on PATH

// after
[tools]
postgres = "16"
# ensure mise shims precede system postgres in PATH (mise activate)
Defensive patterns

Strategy: validation

Validate before calling

# Confirm initdb and postgres come from the same install before initializing
which initdb postgres
initdb --version
postgres --version  # major numbers must match

Try / catch

try {
  mise daemons start
} catch (e) {
  if (String(e).includes("incompatible versions")) {
    console.error("initdb/postgres major mismatch — fix PATH or mise postgres version, then retry.");
  }
}

Prevention

When it happens

Trigger: Daemon preset initialization for postgres where `read_to_string(staged_data/PG_VERSION).trim()` does not equal the major version parsed from `postgres --version` — e.g. initdb 15 is on PATH while postgres resolves to 16, or a mise-installed postgres version differs from a system initdb.

Common situations: A system PostgreSQL (e.g. from Homebrew or apt) puts initdb on PATH while mise's [tools] postgres is used for the server, or the user recently upgraded postgres and PATH/shims still point at the old initdb.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/14b3cb7b40982d0d. Report an issue: GitHub.

Appendix: source

Thrown at src/daemons/presets.rs:252

                bail!("invalid database name");
            }
            let mut child = Command::new("postgres")
                .arg("--single")
                .arg("-D")
                .arg(&staged_data)
                .arg("postgres")
                .stdin(Stdio::piped())
                .spawn()?;
            writeln!(
                child.stdin.take().unwrap(),
                "CREATE DATABASE \"{database}\";"
            )?;
            if !child.wait()?.success() {
                bail!("failed to create database {database}");
            }
        }
        if std::fs::read_to_string(staged_data.join("PG_VERSION"))?.trim() != major {
            bail!("initdb and postgres have incompatible versions");
        }
    } else {
        std::fs::create_dir(&staged_data)?;
    }
    std::fs::write(staged_data.join(".mise-daemon-version"), marker)?;
    std::fs::rename(staged_data, data)?;
    Ok(())
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn presets_render_local_persistent_daemons() {
        for (name, _) in PRESETS {
            let daemon = expand(
                name,
                name,

View on GitHub (pinned to 533346cc37)