lima-vm/lima · error
daemon %#q not defined
Error message
daemon %#q not defined
What it means
After the daemon is confirmed installed, Config.User switches on the daemon name to return the user that runs it (root for socket_vmnet). If the daemon is installed but has no mapping in the switch, it returns 'daemon %#q not defined'. This guards against a name that passed path lookup but has no user rule.
Source
Thrown at pkg/networks/commands.go:91
return filepath.Join(c.Paths.VarRun, fmt.Sprintf("%s_%s.pid", name, daemon))
}
func (c *Config) LogFile(name, daemon, stream string) string {
networksDir, _ := dirnames.LimaNetworksDir()
return filepath.Join(networksDir, fmt.Sprintf("%s_%s.%s.log", name, daemon, stream))
}
func (c *Config) User(daemon string) (osutil.User, error) {
if ok, _ := c.IsDaemonInstalled(daemon); !ok {
daemonPath, _ := c.DaemonPath(daemon)
return osutil.User{}, fmt.Errorf("daemon %#q (path=%#q) is not available", daemon, daemonPath)
}
//nolint:gocritic // singleCaseSwitch: should rewrite switch statement to if statement
switch daemon {
case SocketVMNet:
return osutil.LookupUser("root")
}
return osutil.User{}, fmt.Errorf("daemon %#q not defined", daemon)
}
func (c *Config) MkdirCmd() string {
return fmt.Sprintf("/bin/mkdir -m 775 -p %s", c.Paths.VarRun)
}
func (c *Config) StartCmd(name, daemon string) string {
if ok, _ := c.IsDaemonInstalled(daemon); !ok {
panic(fmt.Errorf("daemon %#q is not available", daemon))
}
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",View on GitHub (pinned to dd909d0973)
Solutions
- Pass networks.SocketVMNet as the daemon name
- Add a case in Config.User for any new daemon introduced in a fork
- Validate the daemon name early (e.g. via DaemonPath) before calling User
Example fix
// before
u, err := cfg.User("socketvmnet")
// after
u, err := cfg.User(networks.SocketVMNet) Defensive patterns
Strategy: type-guard
Validate before calling
if daemon != networks.SocketVMNet {
return fmt.Errorf("no user mapping for daemon %q", daemon)
} Type guard
func hasUserMapping(d string) bool { return d == networks.SocketVMNet } Try / catch
u, err := cfg.User(daemon)
if err != nil {
return fmt.Errorf("daemon %q has no configured user; use socket_vmnet", daemon)
} Prevention
- Use the SocketVMNet constant for all daemon references
- When adding daemons in forks, update both DaemonPath and User
- Fail fast with DaemonPath before calling User
When it happens
Trigger: Calling User(daemon) with a daemon string that is not exactly networks.SocketVMNet — it reaches the fall-through return after the single-case switch.
Common situations: Same root cause as 'unknown daemon type': legacy daemon names or typos passed through caller code; a fork that added a daemon path entry but forgot to add the user-mapping case in User.
Related errors
- c.Paths.SocketVMNet is empty
- network %#q is not defined
- unknown daemon type %#q
- daemon %#q (path=%#q) is not available
- daemon %#q is not available
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/7753f7193769c4e8.
Report an issue: GitHub.