abiosoft/colima · error

error extracting vmnet archive: %w

Error message

error extracting vmnet archive: %w

What it means

Thrown when the extraction of the embedded socket_vmnet tarball into /opt/colima fails. The code runs `sudo sh -c 'cd /opt/colima && tar xfz /tmp/vmnet.tar.gz 2>/dev/null'` via host.RunInteractive; stderr of tar is discarded, so any tar failure (corrupt temp file, disk full, bad archive) or a cancelled/failed sudo invocation surfaces only as this wrapped exit error.

Source

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

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

	return nil
}

var _ process.Dependency = vmnetRunDir{}

type vmnetRunDir struct{}

// Install implements Dependency
func (v vmnetRunDir) Install(host environment.HostActions) error {
	return host.RunInteractive("sudo", "mkdir", "-p", runDir())
}

// Installed implements Dependency
func (v vmnetRunDir) Installed() bool {
	stat, err := os.Stat(runDir())
	return err == nil && stat.IsDir()

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Free disk space and retry `colima start` (install is re-attempted since binaries are missing)
  2. Clear partial state: `sudo rm -rf /opt/colima` then retry so the archive is re-extracted cleanly
  3. Run in an interactive Terminal so the sudo password prompt works
  4. Manually verify extraction works: `sudo tar tvf /tmp/<vmnet.tar.gz>` after reproducing, or check the embedded asset exists in your colima build
  5. If it persists, report the corruption — the `2>/dev/null` hides tar's message, so try the tar command by hand

Example fix

# before
# failed start leaves partial /opt/colima; subsequent starts keep failing
# after
sudo rm -rf /opt/colima
colima start   # reinstalls socket_vmnet from the embedded tarball
Defensive patterns

Strategy: retry

Validate before calling

// Verify the embedded asset and temp-dir writability before install
func preflightVmnetInstall(arch string) error {
    if _, err := embedded.Read("network/vmnet_" + arch + ".tar.gz"); err != nil {
        return err
    }
    f, err := os.CreateTemp("", "vmnet.tar.gz")
    if err != nil {
        return err // /tmp unwritable/full — extraction would fail too
    }
    _ = f.Close()
    _ = os.Remove(f.Name())
    return nil
}

Try / catch

if err != nil && strings.Contains(err.Error(), "error extracting vmnet archive") {
    // extraction already retried fresh each start; if it fails twice, reset state
    if resetErr := exec.Command("sudo", "rm", "-rf", "/opt/colima").Run(); resetErr == nil {
        return fmt.Errorf("vmnet install failed; /opt/colima reset, retry colima start: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: vmnetFile.Install() runs (vmnet binaries missing at /opt/colima/bin/socket_vmnet*) and: the temp file written earlier is corrupt/truncated; /opt/colima disk is full; tar exits non-zero (unsupported format, permissions); the sudo prompt is declined; sudo fails in a non-TTY environment.

Common situations: Disk-full macOS machines; interrupted first run that left a partial state; running `colima start` over ssh without TTY so sudo fails; antivirus/corporate tooling tampering with /opt writes; odd tar behavior on very old macOS versions.

Related errors


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