abiosoft/colima · error

error closing temporary file: %w

Error message

error closing temporary file: %w

What it means

Third error mode of waitForUserEdit: tmp.Close() fails while flushing/closing the temp file after writing. On local filesystems a close error usually means the final flush of buffered data hit ENOSPC or a device-level EIO; on network filesystems it can also surface locking/state errors. The file handle is left in an unknown state and the edit flow aborts.

Source

Thrown at cmd/util.go:37

	if err != nil {
		logrus.Fatal("Error: ", err)
	}
	return colimaApp
}

// waitForUserEdit launches a temporary file with content using editor,
// and waits for the user to close the editor.
// It returns the filename (if saved), empty file name (if aborted), and an error (if any).
func waitForUserEdit(editor string, content []byte) (string, error) {
	tmp, err := os.CreateTemp("", "colima-*.yaml")
	if err != nil {
		return "", fmt.Errorf("error creating temporary file: %w", err)
	}
	if _, err := tmp.Write(content); err != nil {
		return "", fmt.Errorf("error writing temporary file: %w", err)
	}
	if err := tmp.Close(); err != nil {
		return "", fmt.Errorf("error closing temporary file: %w", err)
	}

	if err := launchEditor(editor, tmp.Name()); err != nil {
		return "", err
	}

	// aborted
	if f, err := os.ReadFile(tmp.Name()); err == nil && len(bytes.TrimSpace(f)) == 0 {
		return "", nil
	}

	return tmp.Name(), nil
}

var editors = []string{
	"vim",
	"code --wait --new-window",
	"nano",

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Free space on the temp volume (`df -h "${TMPDIR:-/tmp}"`) and retry
  2. Move TMPDIR to a healthy local volume: `TMPDIR=$HOME/tmp colima start --edit`
  3. If TMPDIR is a network/FUSE mount, stop pointing TMPDIR at it for interactive edits
  4. Repeated EIO on a local disk indicates filesystem/hardware trouble — check with `dmesg`/Disk Utility
Defensive patterns

Strategy: retry

Try / catch

if err := startCmd.Execute(); err != nil {
    var perr *fs.PathError
    if errors.As(err, &perr) {
        switch {
        case errors.Is(perr.Err, syscall.ENOSPC):
            // flush failed at close: free space, retry
        case errors.Is(perr.Err, syscall.EIO):
            // backing filesystem error: switch TMPDIR to a local volume, retry
        }
    }
}

Prevention

When it happens

Trigger: Writing content that fits in the buffer but cannot be flushed at close because the disk/quota filled; TMPDIR on NFS/FUSE with close-time errors; removable media yanked mid-flow.

Common situations: Disk-full conditions detected only at close; TMPDIR pointed at a network share in corporate setups; flaky USB drives hosting /tmp.

Related errors


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