{"record":{"id":"5c0da01e57ecde45","repo":"abiosoft/colima","slug":"failed-to-remove-existing-resolv-conf-w","errorCode":null,"errorMessage":"failed to remove existing resolv.conf: %w","messagePattern":"failed to remove existing resolv\\.conf: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"environment/vm/lima/dns.go","lineNumber":91,"sourceCode":"\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\n\t// restart dnsmasq service to apply changes\n\tif err := l.RunQuiet(\"sudo\", \"systemctl\", \"restart\", \"dnsmasq\"); err != nil {\n\t\treturn fmt.Errorf(\"failed to restart dnsmasq service: %w\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":73,"sourceCodeEnd":107,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/environment/vm/lima/dns.go#L73-L107","documentation":"Step in the guest DNS setup where the existing /etc/resolv.conf is removed (`sudo rm -f /etc/resolv.conf`) so Colima can replace it with a stub pointing at the in-guest dnsmasq. Failure means the rm command failed inside the guest: immutable/attrib-protected resolv.conf (common on hardened images), read-only /etc, or a failing sudo/SSH channel.","triggerScenarios":"Custom or hardened guest images where /etc/resolv.conf is chattr +i or bind-mounted read-only; NetworkManager/systemd-resolved holding the file; broken sudo in the guest. Only triggered in DNS modes that install dnsmasq in the guest.","commonSituations":"Users forcing modified disk images; container Linux variants managing resolv.conf; guest corrupted after abrupt host sleep/shutdown.","solutions":["Retry after a full stop/start of the VM.","If using a custom image, ensure /etc/resolv.conf is a regular writable file (not immutable, not a bind mount).","Switch DNS configuration to a mode that does not rewrite guest resolv.conf (e.g. plain host resolvers via `--dns`), letting the step be skipped.","Recreate the profile (`colima delete && colima start`) when the guest is corrupted."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// with custom guest images, ensure resolv.conf is a plain writable file\n// colima ssh -- lsattr /etc/resolv.conf  (no 'i' flag)\n// colima ssh -- mount | grep resolv.conf (not ro bind mount)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Don't chattr +i resolv.conf in custom images","Avoid DNS modes that rewrite guest resolv.conf on hardened images","Prefer official images"],"tags":["dns","resolv-conf","guest","colima","filesystem"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}