{"record":{"id":"c08709bf06462fd7","repo":"kubernetes/kops","slug":"error-launching-editor-v-c08709","errorCode":null,"errorMessage":"error launching editor: %v","messagePattern":"error launching editor: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/edit_instancegroup.go","lineNumber":198,"sourceCode":"\n\tcontainsError := false\n\n\tfor {\n\t\tbuf := &bytes.Buffer{}\n\t\tresults.header.writeTo(buf)\n\t\tresults.header.flush()\n\n\t\tif !containsError {\n\t\t\tbuf.Write(raw)\n\t\t} else {\n\t\t\tbuf.Write(stripComments(edited))\n\t\t}\n\n\t\t// launch the editor\n\t\teditedDiff := edited\n\t\tedited, file, err = editor.LaunchTempFile(fmt.Sprintf(\"%s-edit-\", filepath.Base(os.Args[0])), ext, buf)\n\t\tif err != nil {\n\t\t\treturn preservedFile(fmt.Errorf(\"error launching editor: %v\", err), results.file, out)\n\t\t}\n\n\t\tif containsError {\n\t\t\tif bytes.Equal(stripComments(editedDiff), stripComments(edited)) {\n\t\t\t\treturn preservedFile(fmt.Errorf(\"%s\", \"Edit cancelled: no valid changes were saved.\"), file, out)\n\t\t\t}\n\t\t}\n\n\t\tif len(results.file) > 0 {\n\t\t\ttry.RemoveFile(results.file)\n\t\t}\n\n\t\tif bytes.Equal(stripComments(raw), stripComments(edited)) {\n\t\t\ttry.RemoveFile(file)\n\t\t\tfmt.Fprintln(out, \"Edit cancelled: no changes made.\")\n\t\t\treturn nil\n\t\t}\n","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/edit_instancegroup.go#L180-L216","documentation":"RunEditInstanceGroup wraps any failure from editor.LaunchTempFile, which creates a temp file and spawns $KOPS_EDITOR/$EDITOR (default vi) to edit the serialized InstanceGroup. If the editor binary is missing, not executable, or the temp file cannot be created/written, the error is wrapped as \"error launching editor\" and returned, with the original file preserved on disk for recovery.","triggerScenarios":"Running `kops edit instancegroup <name>` when no EDITOR/KOPS_EDITOR is set or points to a nonexistent binary; the temp directory is unwritable/full; the resolved ext/format has no registered temp-file writer.","commonSituations":"Running kops in a minimal Docker container or CI job with no editor installed; EDITOR set to a GUI app that fails to launch headless; read-only TMPDIR or full disk.","solutions":["Set a working editor: export KOPS_EDITOR=vim (or EDITOR=nano) before running the command","Verify the editor binary exists in PATH (which $EDITOR) and is executable","Check TMPDIR is writable and has free space (df -h /tmp)","Skip the editor entirely: write the desired YAML to a file and use `kops replace -f` or `kops edit` with the file-based workflow"],"exampleFix":"// before\nkops edit instancegroup nodes  # EDITOR=code (GUI, fails headless)\n// after\nKOPS_EDITOR=vim kops edit instancegroup nodes","handlingStrategy":"validation","validationCode":"editor := os.Getenv(\"KOPS_EDITOR\"); if editor == \"\" { editor = os.Getenv(\"EDITOR\") }\nif editor == \"\" { editor = \"vi\" }\nif _, err := exec.LookPath(editor); err != nil {\n    return fmt.Errorf(\"editor %q not found in PATH: %w\", editor, err)\n}","typeGuard":null,"tryCatchPattern":"if err := runEdit(); err != nil {\n    if strings.Contains(err.Error(), \"error launching editor\") {\n        // fall back to non-interactive workflow: kops get -o yaml > ig.yaml; edit; kops replace -f ig.yaml\n    }\n}","preventionTips":["Always set KOPS_EDITOR or EDITOR to a CLI editor in containers/CI","Verify the editor binary exists with `which $EDITOR` before interactive commands","Ensure TMPDIR is writable and has free space","Use file-based workflows (kops replace -f) for non-interactive automation"],"tags":["cli","editor","environment"],"backgroundTag":"editor-launch-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}