lima-vm/lima · error
template does not define param %#q
Error message
template does not define param %#q
What it means
BuildParamExpressions validates each NAME=VALUE parameter against the set of parameters the target template actually defines (allowedParams). This error is returned when the NAME is not a defined param in the template, so the override would have no effect or produce an invalid yq expression.
Source
Thrown at cmd/limactl/editflags/editflags.go:193
hostPort, guestPort, isStatic, err := ParsePortForward(spec)
if err != nil {
return "", err
}
ports[i] = fmt.Sprintf(`{"guestPort": %q, "hostPort": %q, "static": %v}`, guestPort, hostPort, isStatic)
}
expr := fmt.Sprintf(".portForwards += [%s]", strings.Join(ports, ","))
return expr, nil
}
func BuildParamExpressions(params []string, allowedParams map[string]string) ([]string, error) {
exprs := make([]string, len(params))
for i, param := range params {
key, value, ok := strings.Cut(param, "=")
if !ok {
return nil, fmt.Errorf("invalid parameter %#q, expected NAME=VALUE", param)
}
if _, ok := allowedParams[key]; !ok {
return nil, fmt.Errorf("template does not define param %#q", key)
}
exprs[i] = fmt.Sprintf(".param[%q] = %q", key, value)
}
return exprs, nil
}
func buildMountListExpression(ss []string) (string, error) {
mounts := make([]string, len(ss))
for i, s := range ss {
writable := strings.HasSuffix(s, ":w")
loc, err := localpathutil.Expand(strings.TrimSuffix(s, ":w"))
if err != nil {
return "", err
}
mounts[i] = fmt.Sprintf(`{"location": %q, "mountPoint": %q, "writable": %v}`, loc, loc, writable)
}
expr := fmt.Sprintf("[%s]", strings.Join(mounts, ","))
return expr, nilView on GitHub (pinned to dd909d0973)
Solutions
- Inspect the template and use exactly its declared param names (e.g. --param cpus=4)
- Fix typos in the parameter NAME
- Use the appropriate generic flags (e.g. --cpus) instead of --param when the template has no such param
- Update to a template version that still defines the param
Example fix
// before limactl create template://_default --param cpuCount=4 // after limactl create template://_default --param cpus=4
Defensive patterns
Strategy: validation
Validate before calling
for _, p := range params {
key, _, _ := strings.Cut(p, "=")
if _, ok := allowedParams[key]; !ok {
return fmt.Errorf("template defines no param %q; allowed: %v", key, keysOf(allowedParams))
}
} Type guard
func paramAllowed(key string, allowed map[string]string) bool {
_, ok := allowed[key]
return ok
} Try / catch
exprs, err := editflags.BuildParamExpressions(params, allowedParams)
if err != nil {
return fmt.Errorf("--param rejected: %w (check the template's defined params)", err)
} Prevention
- Read the target template's params section before overriding
- Watch for template renames across Lima versions
- Prefer dedicated flags (--cpus, --memory) over --param when available
When it happens
Trigger: Calling BuildParamExpressions with a key absent from allowedParams, e.g. --param cpuCount=4 against a template whose params only define 'cpus'; also happens when passing params to a template with no params at all.
Common situations: Typos in parameter names (cpus vs cpuCount vs cpu); using params from one template with another template; version drift where a template renamed or removed a param; forgetting the template:// prefix format differences.
Related errors
- invalid parameter %#q, expected NAME=VALUE
- invalid value for static parameter: %#q
- invalid parameter %#q, expected `static=` followed by a bool
- invalid value for number of cpus, must be >= 0
- instance %#q is stopped, run `limactl start %s` to start the
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/4e0c989766874904.
Report an issue: GitHub.