lima-vm/lima · error
field `memory` has an invalid value: %w
Error message
field `memory` has an invalid value: %w
What it means
The `memory` field is parsed with docker/go-units RAMInBytes, which accepts values like "4GiB", "4GB", "4096MB", or bare byte counts. Any unparseable string ("4 Gigs", "4Gi", "4gb ", negative or garbage) produces a parse error wrapped by this message.
Source
Thrown at pkg/limayaml/validate.go:111
}
}
if f.Initrd != nil {
err := validateFileObject(*f.Initrd, fmt.Sprintf("images[%d].initrd", i))
if err != nil {
errs = errors.Join(errs, err)
}
if f.Initrd.Arch != f.Arch {
errs = errors.Join(errs, fmt.Errorf("images[%d].initrd has unexpected architecture %#q, must be %#q", i, f.Initrd.Arch, f.Arch))
}
}
}
if *y.CPUs == 0 {
errs = errors.Join(errs, errors.New("field `cpus` must be set"))
}
if _, err := units.RAMInBytes(*y.Memory); err != nil {
errs = errors.Join(errs, fmt.Errorf("field `memory` has an invalid value: %w", err))
}
if _, err := units.RAMInBytes(*y.Disk); err != nil {
errs = errors.Join(errs, fmt.Errorf("field `disk` has an invalid value: %w", err))
}
for i, disk := range y.AdditionalDisks {
if err := identifiers.Validate(disk.Name); err != nil {
errs = errors.Join(errs, fmt.Errorf("field `additionalDisks[%d].name is invalid`: %w", i, err))
}
}
for i, f := range y.Mounts {
if !filepath.IsAbs(f.Location) && !strings.HasPrefix(f.Location, "~") {
errs = errors.Join(errs, fmt.Errorf("field `mounts[%d].location` must be an absolute path, got %#q",
i, f.Location))
}
// f.Location has already been expanded in FillDefaults(), but that function cannot return errors.View on GitHub (pinned to dd909d0973)
Solutions
- Use an accepted format like `memory: 4GiB` (or "4096MB")
- Drop the space between number and unit (`4 GiB` -> `4GiB`)
- Verify the YAML quoting so the value is a plain scalar string
Example fix
// before memory: 4 GiB // after memory: 4GiB
Defensive patterns
Strategy: validation
Validate before calling
import "github.com/docker/go-units"
func validMemory(mem string) bool {
_, err := units.RAMInBytes(mem)
return err == nil
} Try / catch
if err := limayaml.Validate(y, false); err != nil {
if strings.Contains(err.Error(), "field `memory` has an invalid value") {
return fmt.Errorf("bad memory format (use e.g. 4GiB): %w", err)
}
return err
} Prevention
- Use formats like 4GiB, 4096MB, or plain bytes
- Pre-validate with units.RAMInBytes before writing the template
- Avoid spaces and unsupported suffixes; don't abbreviate GiB as Gi
When it happens
Trigger: `memory` set to a string units.RAMInBytes cannot parse, e.g. `memory: 4Gi`, `memory: 4 G`, or a non-numeric string; Validate() invoked on a YAML whose memory key is malformed.
Common situations: Typos in size suffixes; adding spaces or locale-formatted numbers; using "k"/"ki" inconsistently; quoting mistakes in YAML producing unexpected strings.
Related errors
- invalid value for static parameter: %#q
- invalid parameter %#q, expected `static=` followed by a bool
- invalid parameter %#q, expected NAME=VALUE
- template does not define param %#q
- invalid value for number of cpus, must be >= 0
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/64204bbfcab4948b.
Report an issue: GitHub.