{"record":{"id":"2f05ce1fd144746d","repo":"abiosoft/colima","slug":"failed-to-create-dnsmasq-config-directory-w","errorCode":null,"errorMessage":"failed to create dnsmasq config directory: %w","messagePattern":"failed to create dnsmasq config directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"environment/vm/lima/dns.go","lineNumber":81,"sourceCode":"\t\tdnsServers = nil\n\t\tfor _, dns := range conf.Network.DNSResolvers {\n\t\t\tdnsServers = append(dnsServers, dns.String())\n\t\t}\n\t}\n\tfor _, dns := range dnsServers {\n\t\tfmt.Fprintf(&buf, \"server=%s\", dns)\n\t\tfmt.Fprintln(&buf)\n\t}\n\tfmt.Fprintln(&buf) // for cleaner output\n\n\t// set dnsmasq listening interface and address\n\tfmt.Fprintln(&buf, \"interface=eth0\")\n\tfmt.Fprintln(&buf, \"listen-address=\"+internalIP)\n\tfmt.Fprintln(&buf, \"bind-interfaces\")\n\n\t// ensure dnsmasq config directory exists\n\tif err := l.RunQuiet(\"sudo\", \"mkdir\", \"-p\", \"/etc/dnsmasq.d\"); err != nil {\n\t\treturn fmt.Errorf(\"failed to create dnsmasq config directory: %w\", err)\n\t}\n\n\t// write config to dnsmasq directory\n\tif err := l.Write(\"/etc/dnsmasq.d/01-colima.conf\", buf.Bytes()); err != nil {\n\t\treturn fmt.Errorf(\"failed to write dnsmasq config: %w\", err)\n\t}\n\n\t// remove existing resolv.conf file\n\tif err := l.RunQuiet(\"sudo\", \"rm\", \"-f\", \"/etc/resolv.conf\"); err != nil {\n\t\treturn fmt.Errorf(\"failed to remove existing resolv.conf: %w\", err)\n\t}\n\n\t// replace resolv.conf with a custom one\n\tresolvConf := fmt.Sprintf(\"# Generated by Colima\\n\\nnameserver %s\\n\", internalIP)\n\tif err := l.Write(\"/etc/resolv.conf\", []byte(resolvConf)); err != nil {\n\t\treturn fmt.Errorf(\"failed to write resolv.conf: %w\", err)\n\t}\n","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/environment/vm/lima/dns.go#L63-L99","documentation":"Part of the in-guest DNS setup when the VM is configured to run its own DNS resolver: Colima runs `sudo mkdir -p /etc/dnsmasq.d` inside the guest via SSH. Failure means the guest command returned non-zero: sudo unavailable/broken, guest filesystem read-only, or the SSH session itself failing. This wraps errors from the setupDNS path (surfaces to the user as 'error setting up DNS').","triggerScenarios":"Starting with a DNS setting that enables dnsmasq in the guest (e.g. `--dns` with resolved delegate) while the guest image is broken, the bootstrap of the VM is incomplete, or SSH to the guest is flaky mid-start. Also if the guest OS variant lacks sudo or systemd.","commonSituations":"Custom disk images (forced, unverified) missing expected tooling; VM still booting when the post-start action runs; resource exhaustion in the guest making command execution fail.","solutions":["Retry `colima start`; transient guest boot/SSH races usually clear on a clean restart (`colima stop && colima start`).","If using a custom disk image, verify it includes sudo and a systemd-based Linux userspace, or switch back to the official image.","Check earlier log lines for SSH/bootstrap failures and address those first (the DNS step rarely fails alone).","As a workaround, simplify DNS config (plain `--dns 1.1.1.1` without the in-guest resolver mode) so dnsmasq setup is skipped."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"Go: if err := vm.Start(ctx, conf); err != nil { if strings.Contains(err.Error(), \"error setting up DNS\") && strings.Contains(err.Error(), \"dnsmasq config directory\") { /* retry once after stop; guest boot race */ } }","preventionTips":["Use the official disk image so guest tooling (sudo/systemd) is present","Avoid starting the same profile concurrently","Keep guest disk space available"],"tags":["dns","dnsmasq","guest","ssh","colima"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}