abiosoft/colima · error

error creating temporary file: %w

Error message

error creating temporary file: %w

What it means

First error mode of waitForUserEdit (used by `colima start --edit` and `colima template`): os.CreateTemp("", "colima-*.yaml") fails, so no scratch file for the editor could be created. The wrapped error is almost always a TMPDIR problem: the directory in TMPDIR does not exist, is unwritable, the inode/file-name space is exhausted, or the disk is full.

Source

Thrown at cmd/util.go:31

	"github.com/abiosoft/colima/cli"
	"github.com/sirupsen/logrus"
)

func newApp() app.App {
	colimaApp, err := app.New()
	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

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Check the wrapped error and your temp dir: `echo "$TMPDIR"; ls -ld "${TMPDIR:-/tmp}"; touch "${TMPDIR:-/tmp}/probe"`
  2. Point TMPDIR somewhere writable: `TMPDIR=$HOME/tmp colima start --edit` (create the dir first)
  3. Free space on the volume hosting the temp dir
  4. Fix ownership if /tmp or TMPDIR is not writable by your user

Example fix

# before
$ colima start --edit
Error: error editing config file: error creating temporary file: open /tmp/colima-1234.yaml: permission denied

# after
$ mkdir -p ~/tmp && TMPDIR=~/tmp colima start --edit
Defensive patterns

Strategy: validation

Validate before calling

// Verify the temp dir is usable before any interactive colima command
dir := os.TempDir() // honors TMPDIR
if _, err := os.Stat(dir); err != nil {
    log.Fatalf("TMPDIR %q does not exist: %v", dir, err)
}
if f, err := os.CreateTemp(dir, "probe-*"); err != nil {
    log.Fatalf("cannot create temp files in %s: %v", dir, err)
} else {
    f.Close()
    os.Remove(f.Name())
}

Try / catch

if err := startCmd.Execute(); err != nil {
    var perr *fs.PathError
    if errors.As(err, &perr) && errors.Is(perr.Err, os.ErrPermission) {
        // TMPDIR permission issue: export TMPDIR=$HOME/tmp and retry
    }
}

Prevention

When it happens

Trigger: TMPDIR pointing to a deleted directory; /tmp mounted noexec/read-only or with wrong ownership; ENOSPC on the temp filesystem; system-wide open-file limit reached.

Common situations: CI containers with a broken TMPDIR; macOS disk-pressure conditions; sandboxes that mount /tmp read-only; TMPDIR inherited from a crashed session.

Related errors


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