abiosoft/colima · error
error preparing colima privileged dir: %w
Error message
error preparing colima privileged dir: %w
What it means
Thrown while installing the socket_vmnet binaries for Colima's rootful (vmnet) network mode on macOS. The code shells out to `sudo mkdir -p /opt/colima` via host.RunInteractive; any non-zero exit (sudo password prompt declined, no sudo rights, root filesystem issues) is wrapped in this error. It runs before extracting the embedded vmnet tarball into /opt/colima.
Source
Thrown at daemon/process/vmnet/deps.go:75
// 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)
}
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 DependencyView on GitHub (pinned to c3a5f9184d)
Solutions
- Re-run the command in a real Terminal so the sudo prompt can appear, and enter the admin password when asked
- Verify sudo works: `sudo -v` in the same shell; if it fails, get the account added to Administrators
- Pre-create the dir once: `sudo mkdir -p /opt/colima && sudo chown $(whoami) /opt/colima`, then retry
- If sudo cannot prompt (ssh/CI), add a NOPASSWD sudoers entry for the colima commands or run interactively
- As a workaround use user-mode networking: `colima start --network-driver slirp` (avoids vmnet entirely)
Example fix
# before (fails in non-interactive ssh session) colima start --network-driver shared # after (pre-create dir once, or use slirp) sudo mkdir -p /opt/colima colima start --network-driver shared # or colima start --network-driver slirp
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight: can we sudo and is /opt writable/creatable?
func canPrepareOptDir() error {
if err := exec.Command("sudo", "-n", "true").Run(); err != nil {
return fmt.Errorf("sudo unavailable non-interactively: %w", err)
}
if _, err := os.Stat("/opt/colima"); err == nil {
return nil // already exists
}
return exec.Command("sudo", "-n", "mkdir", "-p", "/opt/colima").Run()
} Try / catch
// err from vmnetFile.Install(host)
if err != nil && strings.Contains(err.Error(), "error preparing colima privileged dir") {
// distinguish sudo-auth failure from filesystem failure
if sudoErr := exec.Command("sudo", "-v").Run(); sudoErr != nil {
return fmt.Errorf("run from an interactive terminal and complete the sudo prompt: %w", err)
}
return fmt.Errorf("/opt/colima could not be created; check permissions/disk: %w", err)
} Prevention
- Run colima start in a real Terminal (TTY) whenever rootful networking is enabled
- Validate `sudo -v` succeeds before scripting colima with vmnet
- For automation, pre-create /opt/colima or configure NOPASSWD for the colima sudoers commands
- Use --network-driver slirp in headless/CI environments
When it happens
Trigger: Colima starts with `--network-driver` shared/bridged (vmnet modes) and /opt/colima does not exist or is not writable; user cancels the interactive sudo password prompt; user lacks sudo privileges (non-admin macOS account); /opt is read-only or a SIP/permission oddity blocks mkdir.
Common situations: First-time setup of colima with rootful networking on a corporate Mac where the user is not an admin; ssh/non-interactive sessions where sudo cannot prompt (NOPASSWD not configured); stale /opt/colima owned by root with wrong modes after a previous failed install; CI runners without a TTY.
Related errors
- error extracting vmnet archive: %w
- error checking vmnet process: %w
- error reading ssh config: %w
- error modifying %s: %w
- error preparing to copy VM: %w
AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15).
Data as JSON: /api/errors/c933d88d3d115595.
Report an issue: GitHub.