kubernetes/kops · error
error launching editor: %v
Error message
error launching editor: %v
What it means
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.
Source
Thrown at cmd/kops/edit_instancegroup.go:198
containsError := false
for {
buf := &bytes.Buffer{}
results.header.writeTo(buf)
results.header.flush()
if !containsError {
buf.Write(raw)
} else {
buf.Write(stripComments(edited))
}
// launch the editor
editedDiff := edited
edited, file, err = editor.LaunchTempFile(fmt.Sprintf("%s-edit-", filepath.Base(os.Args[0])), ext, buf)
if err != nil {
return preservedFile(fmt.Errorf("error launching editor: %v", err), results.file, out)
}
if containsError {
if bytes.Equal(stripComments(editedDiff), stripComments(edited)) {
return preservedFile(fmt.Errorf("%s", "Edit cancelled: no valid changes were saved."), file, out)
}
}
if len(results.file) > 0 {
try.RemoveFile(results.file)
}
if bytes.Equal(stripComments(raw), stripComments(edited)) {
try.RemoveFile(file)
fmt.Fprintln(out, "Edit cancelled: no changes made.")
return nil
}
View on GitHub (pinned to 4c8573c808)
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
Example fix
// before kops edit instancegroup nodes # EDITOR=code (GUI, fails headless) // after KOPS_EDITOR=vim kops edit instancegroup nodes
Defensive patterns
Strategy: validation
Validate before calling
editor := os.Getenv("KOPS_EDITOR"); if editor == "" { editor = os.Getenv("EDITOR") }
if editor == "" { editor = "vi" }
if _, err := exec.LookPath(editor); err != nil {
return fmt.Errorf("editor %q not found in PATH: %w", editor, err)
} Try / catch
if err := runEdit(); err != nil {
if strings.Contains(err.Error(), "error launching editor") {
// fall back to non-interactive workflow: kops get -o yaml > ig.yaml; edit; kops replace -f ig.yaml
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- error launching editor: %v
- Edit cancelled: no valid changes were saved.
- error creating temp dir: %v
- Error too many '=' (%d) in %s
- at least one channel URL is required
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/c08709bf06462fd7.
Report an issue: GitHub.