abiosoft/colima · error

error editing template file: %w

Error message

error editing template file: %w

What it means

Returned by `colima template` when the underlying waitForUserEdit fails: temp-file creation/write/close problems or, most often, a launchEditor failure. launchEditor resolves the editor from --editor, $EDITOR, vscode detection, then vim/code/nano; it errors with 'no editor found in $PATH...' or propagates the editor's non-zero exit status.

Source

Thrown at cmd/template.go:46

		// there are unwarranted []byte to string overheads.
		// not a big deal in this case

		abort, err := embedded.ReadString("defaults/abort.yaml")
		if err != nil {
			return fmt.Errorf("error reading embedded file: %w", err)
		}
		info, err := embedded.ReadString("defaults/template.yaml")
		if err != nil {
			return fmt.Errorf("error reading embedded file: %w", err)
		}
		template, err := templateFileOrDefault()
		if err != nil {
			return fmt.Errorf("error reading template file: %w", err)
		}

		tmpFile, err := waitForUserEdit(templateCmdArgs.Editor, []byte(abort+"\n"+info+"\n"+template))
		if err != nil {
			return fmt.Errorf("error editing template file: %w", err)
		}
		if tmpFile == "" {
			return fmt.Errorf("empty file, template edit aborted")
		}
		defer func() {
			_ = os.Remove(tmpFile)
		}()

		// load and resave template to ensure the format is correct
		cf, err := configmanager.LoadFrom(tmpFile)
		if err != nil {
			return fmt.Errorf("error in template: %w", err)
		}
		if err := configmanager.SaveToFile(cf, templateFile()); err != nil {
			return fmt.Errorf("error saving template: %w", err)
		}

		log.Println("configurations template saved")

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Pass an editor explicitly: `colima template --editor vim` or `EDITOR=vim colima template`
  2. Install any fallback editor: `brew install vim` (or the distro equivalent)
  3. Check TMPDIR writability and disk space if the wrapped error mentions the temp file
  4. As a non-interactive alternative, write the template file directly at the path shown by `colima template --print`

Example fix

# before
$ colima template
Error: error editing template file: no editor found in $PATH, kindly set $EDITOR environment variable and try again

# after
$ colima template --editor nano
Defensive patterns

Strategy: validation

Validate before calling

// Ensure an editor is resolvable before launching `colima template`
have := func() bool {
    if e := os.Getenv("EDITOR"); e != "" {
        if _, err := exec.LookPath(strings.Fields(e)[0]); err == nil {
            return true
        }
    }
    for _, c := range []string{"vim", "code", "nano"} {
        if _, err := exec.LookPath(c); err == nil {
            return true
        }
    }
    return false
}()
if !have {
    log.Fatal("no editor; run `colima template --editor <cmd>` after installing one")
}

Try / catch

if err := templateCmd.Execute(); err != nil {
    switch {
    case strings.Contains(err.Error(), "no editor found in $PATH"):
        // install editor / set $EDITOR / pass --editor
    case strings.Contains(err.Error(), "temporary file"):
        // fix TMPDIR or disk space
    }
}

Prevention

When it happens

Trigger: `colima template` with $EDITOR unset and none of vim/code/nano on PATH (minimal container, stripped server); $EDITOR pointing at a broken command; TMPDIR unwritable causing the temp-file errors.

Common situations: Setting the default template on a headless box; EDITOR set to a GUI editor that errors without a display; code CLI missing inside VS Code remote terminals.

Related errors


AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15). Data as JSON: /api/errors/26f76f91aea32697. Report an issue: GitHub.