abiosoft/colima · error

error creating temp file: %w

Error message

error creating temp file: %w

What it means

vmnetFile.Install stages the embedded tarball by writing it to a temp file (os.CreateTemp("", "vmnet.tar.gz")) before privileged extraction into /opt/colima. This error means the OS refused to create the temp file: TMPDIR unset/pointing to a nonexistent or protected directory (common in launchd-managed daemon contexts with sterile environments), disk/inode exhaustion, or sandbox denial.

Source

Thrown at daemon/process/vmnet/deps.go:61

func (v vmnetFile) bins() []string {
	return []string{BinaryPath, ClientBinaryPath}
}
func (v vmnetFile) Install(host environment.HostActions) error {
	arch := "x86_64"
	if runtime.GOARCH != "amd64" {
		arch = "arm64"
	}

	// read the embedded file
	gz, err := embedded.Read("network/vmnet_" + arch + ".tar.gz")
	if err != nil {
		return fmt.Errorf("error retrieving embedded vmnet file: %w", err)
	}

	// write tar to tmp directory
	f, err := os.CreateTemp("", "vmnet.tar.gz")
	if err != nil {
		return fmt.Errorf("error creating temp file: %w", err)
	}
	if _, err := f.Write(gz); err != nil {
		return fmt.Errorf("error writing temp file: %w", err)
	}
	_ = f.Close() // not a fatal error

	defer func() {
		_ = os.Remove(f.Name())
	}()

	// extract tar to desired location
	dir := optDir
	if err := host.RunInteractive("sudo", "mkdir", "-p", dir); err != nil {
		return fmt.Errorf("error preparing colima privileged dir: %w", err)
	}
	if err := host.RunInteractive("sudo", "sh", "-c", fmt.Sprintf("cd %s && tar xfz %s 2>/dev/null", dir, f.Name())); err != nil {
		return fmt.Errorf("error extracting vmnet archive: %w", err)
	}

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. check and free space: df -h $TMPDIR /tmp
  2. verify writability in the failing context: touch $TMPDIR/colima-probe
  3. set TMPDIR to a writable directory for the process and retry `colima start --network-address`
Defensive patterns

Strategy: retry

Validate before calling

tmp := os.TempDir()
probe, err := os.CreateTemp("", "colima-probe")
if err != nil {
    return fmt.Errorf("TMPDIR %q unusable: %w", tmp, err)
}
_ = probe.Close()
_ = os.Remove(probe.Name())

Try / catch

if _, err := os.CreateTemp("", "vmnet.tar.gz"); err != nil {
    if pe := new(fs.PathError); errors.As(err, &pe) {
        // EACCES/EROFS -> fix TMPDIR; ENOSPC -> free space, then retry
    }
}

Prevention

When it happens

Trigger: TMPDIR invalid or unwritable in the daemon's environment; /tmp full or mounted read-only; macOS sandboxed execution denying the default temp dir.

Common situations: rootful daemon started from a context without the user's env; CI runners with tiny tmpfs; disk quota hit.

Related errors


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