{"record":{"id":"0126e1b0a3e4e9fa","repo":"gastownhall/beads","slug":"legacy-sqlite-migration-requires-cgo","errorCode":null,"errorMessage":"legacy SQLite migration requires CGO","messagePattern":"legacy SQLite migration requires CGO","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/migration/legacysqlite/reader_nocgo.go","lineNumber":13,"sourceCode":"//go:build !cgo\n\npackage legacysqlite\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n)\n\n// Export keeps the command surface available in no-CGO builds.\nfunc Export(context.Context, string, string, io.Writer) error {\n\treturn fmt.Errorf(\"legacy SQLite migration requires CGO\")\n}\n","sourceCodeStart":1,"sourceCodeEnd":15,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/migration/legacysqlite/reader_nocgo.go#L1-L15","documentation":"The legacy SQLite reader needs CGO to link the SQLite driver. In builds compiled without CGO, a stub Export is compiled that keeps the command available but always fails, telling the user the feature requires a CGO-enabled build.","triggerScenarios":"Calling Export (legacy SQLite migration) from a binary built with CGO_ENABLED=0 (e.g. default cross-compiles, distroless/scratch Docker images, or a pure-Go toolchain without a C compiler).","commonSituations":"Running a statically-linked release binary of bd and trying to migrate an old SQLite-based beads database; CI images built with CGO disabled; musl/alpine builds without gcc.","solutions":["Rebuild with CGO enabled: CGO_ENABLED=1 go build ./cmd/bd (requires gcc and libc dev headers).","Use a migration binary built with CGO (official cgo-enabled release) for the one-time legacy migration.","If a CGO build is impossible, export the legacy data on another machine with CGO and import the resulting JSONL on this machine."],"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":"if strings.Contains(err.Error(), \"requires CGO\") {\n    // offer JSONL export/import path instead of direct SQLite read\n}","typeGuard":null,"tryCatchPattern":"if err := legacysqlite.Export(ctx, dbPath, project, w); err != nil {\n    if strings.Contains(err.Error(), \"requires CGO\") {\n        return fmt.Errorf(\"use a CGO-enabled build for legacy migration: %w\", err)\n    }\n    return err\n}","preventionTips":["Build migration tooling with CGO_ENABLED=1","Check build tags before shipping release binaries","Document the CGO requirement for legacy migration"],"tags":["cgo","build","sqlite","migration"],"backgroundTag":"cgo-required-build","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}