{"record":{"id":"31afc975b3134f74","repo":"gastownhall/beads","slug":"embeddeddolt-requires-cgo-build-with-cgo-enabled","errorCode":null,"errorMessage":"embeddeddolt: requires CGO (build with CGO_ENABLED=1)","messagePattern":"embeddeddolt: requires CGO \\(build with CGO_ENABLED=1\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/embeddeddolt/open_stub.go","lineNumber":13,"sourceCode":"//go:build !cgo\n\npackage embeddeddolt\n\nimport (\n\t\"context\"\n\t\"database/sql\"\n\t\"errors\"\n)\n\n// OpenSQL is a stub that returns an error when CGO is not enabled.\nfunc OpenSQL(_ context.Context, _, _, _ string) (*sql.DB, func() error, error) {\n\treturn nil, nil, errors.New(\"embeddeddolt: requires CGO (build with CGO_ENABLED=1)\")\n}\n","sourceCodeStart":1,"sourceCodeEnd":15,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/embeddeddolt/open_stub.go#L1-L15","documentation":"This is the no-CGO build stub of embeddeddolt.OpenSQL. The embedded Dolt driver is cgo-based; when the binary was compiled with CGO_ENABLED=0 the symbol is replaced by this stub which always errors, telling you to rebuild with CGO enabled.","triggerScenarios":"Calling embeddeddolt.OpenSQL in a binary built with CGO_ENABLED=0 (default in many cross-compile/scratch-container builds, or via go build without cgo toolchain).","commonSituations":"Cross-compiling (e.g. GOOS=linux GOARCH=arm64 from a Mac) which disables cgo; distroless/scratch Docker builds; missing C toolchain in CI causing an implicit cgo-less build.","solutions":["Rebuild with CGO_ENABLED=1 (and a working C compiler: gcc/clang)","Install gcc in the build image or use a builder image with the toolchain (e.g. golang images with build-essential)","If CGO cannot be enabled, use the non-embedded (server) Dolt mode instead"],"exampleFix":"// before\nCGO_ENABLED=0 go build -o bd ./cmd/bd\n// after\nCGO_ENABLED=1 go build -o bd ./cmd/bd","handlingStrategy":"fallback","validationCode":"// build-time check\n//go:build cgo\n// or at startup:\nif strings.Contains(err.Error(), \"requires CGO\") { /* fall back to server mode */ }","typeGuard":"func isNoCGOErr(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"requires CGO\")\n}","tryCatchPattern":"store, err := embeddeddolt.Open(ctx, dir, db, branch)\nif err != nil && isNoCGOErr(err) {\n    return openServerModeStore(ctx) // fallback\n}\nreturn err","preventionTips":["Set CGO_ENABLED=1 explicitly in Makefiles and CI build steps","Use builder images with gcc installed","Check `go env CGO_ENABLED` when cross-compiling; cross-compile turns cgo off by default"],"tags":["go","cgo","build","embedded-dolt"],"backgroundTag":"cgo-disabled-build","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}