{"record":{"id":"48b288790fa50227","repo":"abiosoft/colima","slug":"error-saving-settings-w","errorCode":null,"errorMessage":"error saving settings: %w","messagePattern":"error saving settings: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"environment/vm/lima/config.go","lineNumber":46,"sourceCode":"func (l limaVM) Get(key string) string {\n\tif val, ok := l.getConf()[key]; ok {\n\t\treturn val\n\t}\n\n\treturn \"\"\n}\n\nfunc (l limaVM) Set(key, value string) error {\n\tobj := l.getConf()\n\tobj[key] = value\n\n\tb, err := json.Marshal(obj)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error marshalling settings to json: %w\", err)\n\t}\n\n\tif err := l.Run(\"sudo\", \"mkdir\", \"-p\", filepath.Dir(configFile)); err != nil {\n\t\treturn fmt.Errorf(\"error saving settings: %w\", err)\n\t}\n\n\tif err := l.Write(configFile, b); err != nil {\n\t\treturn fmt.Errorf(\"error saving settings: %w\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":28,"sourceCodeEnd":55,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/environment/vm/lima/config.go#L28-L55","documentation":"Raised by limaVM.Set when 'sudo mkdir -p <dir-of-configFile>' fails inside the guest before writing the VM-side settings/config file (the lima config store used for keys like the kubernetes ConfigKey). The wrapped error is the guest command's stderr/exit status, so the VM being unreachable or sudo misbehaving is the usual root cause.","triggerScenarios":"Executing Set(...) while the Lima VM is stopped or still booting (limactl ssh fails); guest SSH broken after an interrupted start; sudo in the guest requiring interaction; guest filesystem read-only or full; limactl missing on the host PATH so the command cannot even launch.","commonSituations":"'colima start' races where settings are written before cloud-init finished; VM wedged after host sleep/resume; disk space exhausted by images; partial upgrade of lima leaving limactl shim broken.","solutions":["Confirm the VM is up and healthy: 'colima status', 'colima ssh -- true'; restart it ('colima stop && colima start') so Set re-runs.","Check guest disk and filesystem: 'colima ssh -- df -h' and 'colima ssh -- sudo touch /var/lib/colima/test' to probe writability.","If limactl itself is the failure (check the wrapped err string), reinstall/relaunch lima (brew reinstall lima) and retry.","Recreate the VM when the guest is unrecoverable: 'colima delete -f && colima start' (expect settings reset)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// verify the guest is reachable before writing settings\nif err := l.Run(\"true\"); err != nil {\n    return fmt.Errorf(\"guest unreachable; start the VM before saving settings: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := l.Run(\"sudo\", \"mkdir\", \"-p\", filepath.Dir(configFile)); err != nil {\n    if strings.Contains(err.Error(), \"not running\") || strings.Contains(err.Error(), \"exit status 255\") {\n        return fmt.Errorf(\"error saving settings (VM not up): %w\", err)\n    }\n    return fmt.Errorf(\"error saving settings: %w\", err)\n}","preventionTips":["Write settings only when 'colima status' reports the VM running.","Never kill -9 the VM; use colima stop so config writes aren't interleaved.","Keep guest disk headroom for config/state writes."],"tags":["lima","guest","settings","sudo","filesystem"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}