{"record":{"id":"cd34f0ed8050ee34","repo":"abiosoft/colima","slug":"error-editing-config-file-w","errorCode":null,"errorMessage":"error editing config file: %w","messagePattern":"error editing config file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/start.go","lineNumber":682,"sourceCode":"// editConfigFile launches an editor to edit the config file.\nfunc editConfigFile() (config.Config, error) {\n\tvar c config.Config\n\n\t// preserve the current file in case the user terminates\n\tcurrentFile, err := os.ReadFile(config.CurrentProfile().File())\n\tif err != nil {\n\t\treturn c, fmt.Errorf(\"error reading config file: %w\", err)\n\t}\n\n\t// prepend the config file with termination instruction\n\tabort, err := embedded.ReadString(\"defaults/abort.yaml\")\n\tif err != nil {\n\t\tlog.Warnln(fmt.Errorf(\"unable to read embedded file: %w\", err))\n\t}\n\n\ttmpFile, err := waitForUserEdit(startCmdArgs.Flags.Editor, []byte(abort+\"\\n\"+string(currentFile)))\n\tif err != nil {\n\t\treturn c, fmt.Errorf(\"error editing config file: %w\", err)\n\t}\n\n\t// if file is empty, abort\n\tif tmpFile == \"\" {\n\t\treturn c, fmt.Errorf(\"empty file, startup aborted\")\n\t}\n\n\tdefer func() {\n\t\t_ = os.Remove(tmpFile)\n\t}()\n\tif startCmdArgs.Flags.SaveConfig {\n\t\tif err := configmanager.SaveFromFile(tmpFile); err != nil {\n\t\t\treturn c, err\n\t\t}\n\t}\n\treturn configmanager.LoadFrom(tmpFile)\n}\n","sourceCodeStart":664,"sourceCodeEnd":700,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/cmd/start.go#L664-L700","documentation":"Returned by editConfigFile when the underlying waitForUserEdit call fails: either the temp file could not be created/written/closed, or — most commonly — launchEditor failed. launchEditor resolves the editor from --editor, $EDITOR, a vscode-terminal heuristic, then a vim/code/nano fallback list, and errors with 'no editor found in $PATH...' or the editor process's non-zero exit.","triggerScenarios":"`colima start --edit` with $EDITOR pointing to a nonexistent command; headless/SSH session with none of vim/code/nano installed; the editor process exits non-zero (e.g. sh -c '$EDITOR file' fails); TMPDIR unwritable.","commonSituations":"Minimal containers or servers without an editor installed; EDITOR set to a GUI app that returns immediately with an error; vscode 'code' CLI not on PATH inside the integrated terminal.","solutions":["Set a working editor explicitly: `EDITOR=vim colima start --edit` (or the --editor flag)","Install an editor: `brew install vim` / apt-get install vim-tiny in containers","Skip the interactive editor entirely: write the YAML yourself and start with the file, or use flags instead of --edit","If the wrapped error mentions temp files, check TMPDIR is writable and disk has space"],"exampleFix":"# before\n$ colima start --edit\nError: error editing config file: no editor found in $PATH, kindly set $EDITOR environment variable and try again\n\n# after\n$ EDITOR=nano colima start --edit","handlingStrategy":"validation","validationCode":"// Replicate launchEditor's resolution before opening an interactive edit\neditor := os.Getenv(\"EDITOR\")\nif editor != \"\" {\n    if _, err := exec.LookPath(strings.Fields(editor)[0]); err != nil {\n        log.Fatalf(\"$EDITOR %q not found in PATH\", editor)\n    }\n} else {\n    found := false\n    for _, cand := range []string{\"vim\", \"code\", \"nano\"} {\n        if _, err := exec.LookPath(cand); err == nil {\n            found = true\n            break\n        }\n    }\n    if !found {\n        log.Fatal(\"no editor available; set $EDITOR or install vim/nano\")\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := editConfigFile(); err != nil {\n    if strings.Contains(err.Error(), \"no editor found in $PATH\") {\n        // guide user: set EDITOR or install an editor, then retry\n    }\n    if strings.Contains(err.Error(), \"temporary file\") {\n        // TMPDIR/disk problem, not an editor problem\n    }\n}","preventionTips":["Export a known-good EDITOR in shell profiles and CI images","Install at least one of vim/nano on headless machines that will use interactive colima commands","Prefer non-interactive flags over --edit in scripts"],"tags":["editor","interactive","environment","edit"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}