abiosoft/colima · error

empty file, template edit aborted

Error message

empty file, template edit aborted

What it means

Returned by `colima template` when the editor buffer is saved containing only whitespace: waitForUserEdit returns the empty-name abort convention and the command converts it into this error, exiting non-zero. Clearing the file is the designed abort gesture for template editing.

Source

Thrown at cmd/template.go:49

		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")

		return nil
	},

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Treat this as a clean abort if that was the intent — the template file on disk is untouched
  2. Re-run `colima template` and save with content (or quit without deleting everything) to keep or change the template
  3. Non-interactively reset the template by deleting the file at `colima template --print`'s path; colima then falls back to the embedded default
Defensive patterns

Strategy: try-catch

Try / catch

err := templateCmd.Execute()
if err != nil && err.Error() == "empty file, template edit aborted" {
    // deliberate abort; the persisted template is unchanged
    err = nil
}

Prevention

When it happens

Trigger: During `colima template`, deleting all buffer content and saving before closing; automation that truncates the temp file.

Common situations: Users intending to cancel the template edit; accidental select-all deletion; scripts expecting exit code 0.

Related errors


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