{"record":{"id":"c89a5c2cf08907fe","repo":"gastownhall/beads","slug":"dolt-init-w-s","errorCode":null,"errorMessage":"dolt init: %w\n%s","messagePattern":"dolt init: %w\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/doltserver/doltserver.go","lineNumber":1948,"sourceCode":"\tif err := os.MkdirAll(doltDir, config.BeadsDirPerm); err != nil {\n\t\treturn fmt.Errorf(\"creating dolt directory: %w\", err)\n\t}\n\n\tdotDolt := filepath.Join(doltDir, \".dolt\")\n\n\tif _, err := os.Stat(dotDolt); err == nil {\n\t\t// .dolt/ exists — seed the marker if missing.\n\t\t// This is the non-destructive path: we just mark existing databases\n\t\t// as known. The destructive recovery path (RecoverPreV56DoltDir) is\n\t\t// triggered separately during version upgrades.\n\t\t_ = MarkDoltDirCompatible(doltDir)\n\t\treturn nil // Already initialized\n\t}\n\n\tcmd := exec.Command(\"dolt\", \"init\")\n\tcmd.Dir = doltDir\n\tif out, err := cmd.CombinedOutput(); err != nil {\n\t\treturn fmt.Errorf(\"dolt init: %w\\n%s\", err, out)\n\t}\n\n\t// Write version marker so future runs know this database is compatible.\n\t_ = MarkDoltDirCompatible(doltDir)\n\n\treturn nil\n}\n\n// RecoverPreV56DoltDir removes and reinitializes a dolt database that was\n// created by a pre-0.56 bd version. Call this during version upgrade detection\n// (e.g., from autoMigrateOnVersionBump when previousVersion < 0.56).\n//\n// Pre-0.56 databases used embedded Dolt mode with a different Dolt library\n// version that may produce nil DoltDB values, causing panics (GH#2137).\n// The data is unrecoverable — the fix is to start fresh.\n//\n// Returns true if recovery was performed, false if not needed.\nfunc RecoverPreV56DoltDir(doltDir string) (bool, error) {","sourceCodeStart":1930,"sourceCodeEnd":1966,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/doltserver/doltserver.go#L1930-L1966","documentation":"Returned by ensureDoltInit when executing the external 'dolt init' command in a fresh dolt directory exits non-zero; the message includes both the exec error and the combined stdout/stderr output from the dolt CLI. bd shells out to the dolt binary to initialize the repository, so any dolt-side failure (or the binary being unusable) surfaces here.","triggerScenarios":"ensureDoltInit finds no .dolt/ directory and runs exec.Command(\"dolt\", \"init\") in doltDir; it fails when the dolt binary is missing from PATH, too old/incompatible, or dolt init itself rejects the directory (corrupt parent, permissions, another dolt process holding it).","commonSituations":"Dolt not installed or not on PATH in CI/containers after bd upgrade to server-only mode; dolt binary version mismatch with the database format; running inside a container without the dolt executable; dolt init reporting an existing/incompatible repository.","solutions":["Install the Dolt CLI (or add it to PATH) and verify: dolt version — bd server mode requires a working dolt binary","Read the trailing command output in the error message; it contains dolt's own reason (e.g. 'repository already exists') and address it","If the output indicates a corrupt/legacy repo, remove the .dolt directory and let bd reinitialize: rm -rf <doltDir>/.dolt","Ensure the dolt binary is recent enough and matches what bd expects (upgrade dolt via its official installer)"],"exampleFix":"// before (container without dolt)\n# error: dolt init: exec: \"dolt\": executable file not found in $PATH\n// after (Dockerfile)\nRUN curl -L https://github.com/dolthub/dolt/releases/latest/download/dolt-linux-amd64.tar.gz | tar -xz && \\\n    mv dolt-linux-amd64/dolt /usr/local/bin/\n","handlingStrategy":"fallback","validationCode":"out, err := exec.LookPath(\"dolt\")\nif err != nil {\n    return fmt.Errorf(\"dolt CLI not found in PATH; install Dolt before running bd server mode\")\n}\nif v, err := exec.Command(out, \"version\").Output(); err != nil {\n    return fmt.Errorf(\"dolt binary not runnable: %w\", err)\n} else {\n    _ = v\n}","typeGuard":null,"tryCatchPattern":"if err := ensureDoltInit(doltDir); err != nil {\n    var exitErr *exec.ExitError\n    if errors.As(err, &exitErr) {\n        // CombinedOutput is embedded in the message; surface dolt's own stderr to the user\n        return fmt.Errorf(\"dolt init failed; see dolt output above; check dolt version compatibility\")\n    }\n    return err\n}","preventionTips":["Install and keep the Dolt CLI in PATH wherever bd runs, including CI images","Pin/upgrade dolt to a version compatible with your bd release","Before upgrading bd, run `dolt version` to confirm the binary works","Check that .dolt is not left in a corrupt half-initialized state before re-running init"],"tags":["dolt","external-command","cli","initialization"],"backgroundTag":"dolt-init-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}