{"record":{"id":"4f9921cf26c82dcf","repo":"abiosoft/colima","slug":"error-creating-cni-config-dir-w","errorCode":null,"errorMessage":"error creating cni config dir: %w","messagePattern":"error creating cni config dir: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"environment/container/kubernetes/cni.go","lineNumber":19,"sourceCode":"package kubernetes\n\nimport (\n\t_ \"embed\"\n\t\"fmt\"\n\t\"path/filepath\"\n\n\t\"github.com/abiosoft/colima/cli\"\n\t\"github.com/abiosoft/colima/embedded\"\n\t\"github.com/abiosoft/colima/environment\"\n)\n\nfunc installCniConfig(guest environment.GuestActions, a *cli.ActiveCommandChain) {\n\t// fix cni config\n\ta.Add(func() error {\n\t\tflannelFile := \"/etc/cni/net.d/10-flannel.conflist\"\n\t\tcniConfDir := filepath.Dir(flannelFile)\n\t\tif err := guest.Run(\"sudo\", \"mkdir\", \"-p\", cniConfDir); err != nil {\n\t\t\treturn fmt.Errorf(\"error creating cni config dir: %w\", err)\n\t\t}\n\n\t\tflannel, err := embedded.Read(\"k3s/flannel.json\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error reading embedded flannel config: %w\", err)\n\t\t}\n\t\treturn guest.Write(flannelFile, flannel)\n\t})\n}\n","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/environment/container/kubernetes/cni.go#L1-L29","documentation":"During k3s provisioning, colima creates /etc/cni/net.d inside the guest VM ('sudo mkdir -p') before writing the flannel conflist, and that mkdir failed. Because everything runs over the guest runner, this almost always means the guest session/VM itself is unhealthy rather than a CNI-specific problem.","triggerScenarios":"guest.Run('sudo','mkdir','-p','/etc/cni/net.d') errors: SSH to guest broken, guest disk full or read-only, sudo failure, or VM stopped mid-chain.","commonSituations":"colima start interrupted then resumed, guest disk exhausted by images, custom guest image without sudo, VM crashed during provisioning.","solutions":["Retry from a clean state: 'colima stop && colima start'","Check guest disk: 'colima ssh -- df -h'","Verify the dir manually: 'colima ssh -- sudo mkdir -p /etc/cni/net.d'","Recreate the VM if the guest is corrupted: 'colima delete && colima start'"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// cheap guest health gate before the chain step\nif err := guest.RunQuiet(\"true\"); err != nil {\n    return fmt.Errorf(\"guest unreachable before cni setup: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := guest.Run(\"sudo\", \"mkdir\", \"-p\", cniConfDir); err != nil {\n    return fmt.Errorf(\"error creating cni config dir: %w\", err)\n    // guest fs/ssh issues: a full 'colima stop && colima start' is the reliable retry\n}","preventionTips":["Keep guest disk below ~90% usage","Use 'colima stop' rather than killing the VM process","Avoid mounting /etc of the guest read-only in custom images"],"tags":["kubernetes","cni","vm","filesystem"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}