lima-vm/lima · critical

unexpected daemon %#q

Error message

unexpected daemon %#q

What it means

StartCmd ends with a default case that panics with 'unexpected daemon %#q' if the daemon name was not dispatched to a known branch. This can only be hit after the earlier IsDaemonInstalled panic check passed, indicating a daemon string unknown to the command builder — the final guard of the daemon dispatch chain.

Source

Thrown at pkg/networks/commands.go:120

	var cmd string
	switch daemon {
	case SocketVMNet:
		nw := c.Networks[name]
		if c.Paths.SocketVMNet == "" {
			panic("c.Paths.SocketVMNet is empty")
		}
		cmd = fmt.Sprintf("%s --pidfile=%s --socket-group=%s --vmnet-mode=%s",
			c.Paths.SocketVMNet, c.PIDFile(name, SocketVMNet), c.Group, nw.Mode)
		switch nw.Mode {
		case ModeBridged:
			cmd += fmt.Sprintf(" --vmnet-interface=%s", nw.Interface)
		case ModeHost, ModeShared:
			cmd += fmt.Sprintf(" --vmnet-gateway=%s --vmnet-dhcp-end=%s --vmnet-mask=%s",
				nw.Gateway, nw.DHCPEnd, nw.NetMask)
		}
		cmd += " " + c.Sock(name)
	default:
		panic(fmt.Errorf("unexpected daemon %#q", daemon))
	}
	return cmd
}

func (c *Config) StopCmd(name, daemon string) string {
	return fmt.Sprintf("/usr/bin/pkill -F %s", c.PIDFile(name, daemon))
}

View on GitHub (pinned to dd909d0973)

Solutions

  1. Only pass networks.SocketVMNet to StartCmd
  2. If supporting a new daemon in a fork, add a case to the StartCmd switch
  3. Validate the daemon name against the supported set before building the command

Example fix

// before
cmd := cfg.StartCmd(name, "vde_vmnet") // panics: unexpected daemon
// after
cmd := cfg.StartCmd(name, networks.SocketVMNet)
Defensive patterns

Strategy: type-guard

Validate before calling

if daemon != networks.SocketVMNet {
    return fmt.Errorf("StartCmd supports only socket_vmnet, got %q", daemon)
}

Type guard

func startCmdSupports(d string) bool { return d == networks.SocketVMNet }

Try / catch

func safeStartCmd(cfg *networks.Config, name, daemon string) (cmd string, err error) {
    defer func() { if r := recover(); r != nil { err = fmt.Errorf("%v", r) } }()
    return cfg.StartCmd(name, daemon), nil
}

Prevention

When it happens

Trigger: Calling StartCmd with a daemon value that passed IsDaemonInstalled (possibly via modified/forked behavior) but is not networks.SocketVMNet, hitting the switch default.

Common situations: Forks or patched builds where IsDaemonInstalled accepts extra daemons but StartCmd was not extended; test code passing mock daemon names; typos that coincidentally pass a loose install check.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/00bd65b4fd8647ba. Report an issue: GitHub.