{"record":{"id":"941fb6a307b35a08","repo":"abiosoft/colima","slug":"error-reading-config-file-w-941fb6","errorCode":null,"errorMessage":"error reading config file: %w","messagePattern":"error reading config file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/yamlutil/yaml.go","lineNumber":44,"sourceCode":"// Save saves the config.\nfunc Save(c config.Config, file string) error {\n\tb, err := encodeYAML(c)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err := os.WriteFile(file, b, 0644); err != nil {\n\t\treturn fmt.Errorf(\"error writing yaml file: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc encodeYAML(conf config.Config) ([]byte, error) {\n\tvar doc yaml.Node\n\n\tf, err := embedded.Read(\"defaults/colima.yaml\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading config file: %w\", err)\n\t}\n\n\tif err := yaml.Unmarshal(f, &doc); err != nil {\n\t\treturn nil, fmt.Errorf(\"embedded default config is invalid yaml: %w\", err)\n\t}\n\n\tif l := len(doc.Content); l != 1 {\n\t\treturn nil, fmt.Errorf(\"unexpected error during yaml decode: doc has multiple children of len %d\", l)\n\t}\n\troot := doc.Content[0]\n\n\t// get all nodes\n\tnodeVals := map[string]*yaml.Node{}\n\tif err := traverseNode(\"\", root, nodeVals); err != nil {\n\t\treturn nil, fmt.Errorf(\"error traversing yaml node: %w\", err)\n\t}\n\n\t// get all node values","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/util/yamlutil/yaml.go#L26-L62","documentation":"encodeYAML (util/yamlutil/yaml.go:44) reads the template document embedded/defaults/colima.yaml via embedded.Read; failure means the embedded filesystem in the running binary does not contain that asset. This is not a user-configuration problem — it indicates a broken or incomplete build (embed directive not applied, partial checkout, truncated/corrupted binary). The config-save path depends on it, so colima cannot persist settings until fixed.","triggerScenarios":"Running a colima binary built from a tree where the embedded dir was excluded (wrong build tags, stripped assets, `go build` from a partial archive); a truncated download of the release binary; antivirus/quarantine mangling the Mach-O with embedded FS.","commonSituations":"Custom forks with restructured directories that broke the embed.FS path; binaries copied between machines with corruption; building with tools that prune embedded files to shrink binaries.","solutions":["Reinstall the official build: `brew reinstall colima` (or re-download the release artifact)","Rebuild from a clean, full checkout and confirm the embed directive covers embedded/defaults/colima.yaml","Verify binary integrity (sha256 against the release manifest) to rule out truncation/corruption","In forks, keep the embedded assets path stable or update embedded.Read accordingly"],"exampleFix":"# before (fork broke embed paths)\n$ ./colima start\nerror reading config file: open defaults/colima.yaml: file does not exist\n\n# after\n$ brew reinstall colima\n$ colima start","handlingStrategy":"fallback","validationCode":"// for colima forks: verify embedded assets at process start\nif _, err := embedded.Read(\"defaults/colima.yaml\"); err != nil {\n    log.Fatal(\"binary missing embedded defaults — rebuild from a full checkout\")\n}","typeGuard":null,"tryCatchPattern":"if err := util.Save(cfg, file); err != nil {\n    if strings.Contains(err.Error(), \"error reading config file\") {\n        // binary-level defect: reinstall rather than retry\n        return fmt.Errorf(\"colima install is broken (missing embedded defaults) — reinstall colima\")\n    }\n    return err\n}","preventionTips":["Install colima from official releases or a clean `go install`","In forks, keep embedded/ paths intact and covered by build tags","Verify release checksums after downloading","Add a CI test that reads every embedded asset"],"tags":["yaml","embedded","build","binary-corruption"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}