{"record":{"id":"5fc37ea9062c81a4","repo":"gastownhall/beads","slug":"errnocgo","errorCode":"errNoCGO","errorMessage":"embeddeddolt: requires CGO (build with CGO_ENABLED=1)","messagePattern":"embeddeddolt: requires CGO \\(build with CGO_ENABLED=1\\)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/embeddeddolt/store_stub.go","lineNumber":17,"sourceCode":"//go:build !cgo\n\npackage embeddeddolt\n\nimport (\n\t\"context\"\n\t\"errors\"\n)\n\n// EmbeddedDoltStore is a stub for builds without CGO.\ntype EmbeddedDoltStore struct {\n\tdataDir  string\n\tdatabase string\n\tbranch   string\n}\n\nvar errNoCGO = errors.New(\"embeddeddolt: requires CGO (build with CGO_ENABLED=1)\")\n\n// Open returns an error when CGO is not enabled.\nfunc Open(_ context.Context, _, _, _ string) (*EmbeddedDoltStore, error) {\n\treturn nil, errNoCGO\n}\n\n// OpenReadOnly returns an error when CGO is not enabled.\nfunc OpenReadOnly(_ context.Context, _, _, _ string) (*EmbeddedDoltStore, error) {\n\treturn nil, errNoCGO\n}\n\n// OpenForPreviewCommand returns an error when CGO is not enabled.\nfunc OpenForPreviewCommand(_ context.Context, _, _, _ string) (*EmbeddedDoltStore, error) {\n\treturn nil, errNoCGO\n}\n\n// OpenForReadOnlyCommand returns an error when CGO is not enabled.\nfunc OpenForReadOnlyCommand(_ context.Context, _, _, _ string) (*EmbeddedDoltStore, error) {","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/embeddeddolt/store_stub.go#L1-L35","documentation":"errNoCGO is the sentinel returned by every embeddeddolt store constructor (Open, OpenReadOnly, OpenForPreviewCommand, OpenForReadOnlyCommand, OpenForWorkingSetReconcile) when the package is compiled without CGO. The embedded Dolt engine requires cgo, so the stub package replaces real constructors with one that always fails with this message.","triggerScenarios":"Any EmbeddedDoltStore open call in a binary built with CGO_ENABLED=0 — cross-compilation, missing C toolchain, or Docker scratch builds.","commonSituations":"CI cross-compile jobs (CGO defaults off when cross-compiling); minimal build containers without gcc; GOFLAGS or CGO_ENABLED=0 set in the environment.","solutions":["Rebuild with CGO_ENABLED=1 and an available C compiler","Add gcc/build-essential to the build container","Verify with `go env CGO_ENABLED` that cgo is enabled for the build; fall back to server-mode Dolt if cgo is impossible"],"exampleFix":"// before\nCGO_ENABLED=0 go build ./cmd/bd\n// after\nCGO_ENABLED=1 go build ./cmd/bd","handlingStrategy":"fallback","validationCode":"// runtime sentinel check\nif errors.Is(err, errNoCGO) || strings.Contains(err.Error(), \"requires CGO\") { /* fallback */ }","typeGuard":"func isCGOUnavailable(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"requires CGO\")\n}","tryCatchPattern":"store, err := embeddeddolt.Open(ctx, dir, db, branch)\nif isCGOUnavailable(err) {\n    return useServerModeDolt(ctx) // fallback path\n}\nreturn err","preventionTips":["Always build with CGO_ENABLED=1 for embedded mode; pin it in Makefile/CI","Install a C toolchain (gcc/clang) in build containers","Detect cgo availability at startup and warn or fall back to server mode"],"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"}