{"record":{"id":"28fcd6e04c2c83dd","repo":"abiosoft/colima","slug":"error-preparing-config-file-w","errorCode":null,"errorMessage":"error preparing config file: %w","messagePattern":"error preparing config file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/start.go","lineNumber":106,"sourceCode":"\t},\n\tPreRunE: func(cmd *cobra.Command, args []string) error {\n\t\t// validate Lima version\n\t\tif err := core.LimaVersionSupported(); err != nil {\n\t\t\treturn fmt.Errorf(\"lima compatibility error: %w\", err)\n\t\t}\n\n\t\t// combine args and current config file(if any)\n\t\tprepareConfig(cmd)\n\n\t\t// validate config\n\t\tif err := configmanager.ValidateConfig(startCmdArgs.Config); err != nil {\n\t\t\treturn fmt.Errorf(\"error in config: %w\", err)\n\t\t}\n\n\t\t// persist in preparation for application start\n\t\tif startCmdArgs.Flags.SaveConfig {\n\t\t\tif err := configmanager.Save(startCmdArgs.Config); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error preparing config file: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\t// validate and set downloader if flag is specified (takes precedence over env var)\n\t\tif cmd.Flag(\"downloader\").Changed {\n\t\t\tnormalized, err := downloader.ValidateDownloader(startCmdArgs.Flags.Downloader)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tdownloader.SetDownloader(normalized)\n\t\t}\n\n\t\treturn nil\n\t},\n}\n\nconst (\n\tdefaultCPU               = 2","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/cmd/start.go#L88-L124","documentation":"Raised in PreRunE of `colima start` when --save-config (-s) is set and configmanager.Save fails to persist the merged config to the current profile's config file. Save serializes to YAML and writes via yamlutil.Save to config.CurrentProfile().File(), so failures are filesystem-level: unreadable/unwritable path, permission denied, disk full, or a directory where the file should be.","triggerScenarios":"`colima start -s ...` when ~/.colima (or the COLIMA_HOME/XDG config dir) has wrong ownership or is read-only; HOME unset so the profile path cannot resolve; disk full at write time.","commonSituations":"Running colima under a different user/sudo so ~/.colima is root-owned; read-only or full disk; HOME pointing to a nonexistent directory in CI or launchd contexts.","solutions":["Inspect the wrapped error for the path and syscall (permission denied vs no space etc.)","Fix ownership/permissions of the config dir: `ls -la ~/.colima` and `sudo chown -R \"$USER\" ~/.colima` if it is root-owned","Free disk space or repair the filesystem if the write failed with ENOSPC/EIO","Ensure HOME (or COLIMA_HOME) is set and writable in the environment invoking colima"],"exampleFix":"# before\n$ colima start -s --cpus 4\nError: error preparing config file: open ~/.colima/_config/colima.yaml: permission denied\n\n# after\n$ sudo chown -R \"$USER\" ~/.colima\n$ colima start -s --cpus 4","handlingStrategy":"validation","validationCode":"// Before `colima start -s`: ensure the profile config path is writable\nhome, _ := os.UserHomeDir()\ndir := filepath.Join(home, \".colima\") // or honor COLIMA_HOME / XDG_CONFIG_HOME\nif info, err := os.Stat(dir); err != nil || !info.IsDir() {\n    if err := os.MkdirAll(dir, 0o755); err != nil {\n        log.Fatalf(\"cannot create config dir: %v\", err)\n    }\n}\nif probe, err := os.CreateTemp(dir, \"probe-*\"); err != nil {\n    log.Fatalf(\"config dir not writable: %v\", err)\n} else {\n    probe.Close()\n    os.Remove(probe.Name())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never run colima under sudo (creates root-owned ~/.colima)","Keep HOME or COLIMA_HOME set and writable in automation environments","Monitor disk space; config writes fail hard on ENOSPC"],"tags":["config","filesystem","permissions","save-config"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}