lima-vm/lima · error

field `additionalDisks[%d].name is invalid`: %w

Error message

field `additionalDisks[%d].name is invalid`: %w

What it means

Each entry of `additionalDisks` must have a name that passes identifiers.Validate (a valid disk identifier). When a disk name is empty or contains invalid characters, this error is joined into the validation error list with the underlying reason.

Source

Thrown at pkg/limayaml/validate.go:120

			}
		}
	}

	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.
		loc, err := localpathutil.Expand(f.Location)
		if err != nil {
			errs = errors.Join(errs, fmt.Errorf("field `mounts[%d].location` refers to an unexpandable path: %#q: %w", i, f.Location, err))
		}
		st, err := os.Stat(loc)
		if err != nil {
			if !errors.Is(err, os.ErrNotExist) {
				errs = errors.Join(errs, fmt.Errorf("field `mounts[%d].location` refers to an inaccessible path: %#q: %w", i, f.Location, err))
			}

View on GitHub (pinned to dd909d0973)

Solutions

  1. Set a valid `name` for every additionalDisks entry (letters, digits, dashes; non-empty)
  2. Create the disk first if it does not exist: `limactl disk create NAME --size 10GiB`
  3. Re-run `limactl template validate <file>` to confirm all additionalDisks names pass

Example fix

// before
additionalDisks:
  - name: my disk/1
// after
additionalDisks:
  - name: my-disk-1
Defensive patterns

Strategy: validation

Validate before calling

function validDiskName(n) { return typeof n === 'string' && /^[A-Za-z0-9][A-Za-z0-9_.-]*$/.test(n) }
// check every entry: (cfg.additionalDisks||[]).every(d => validDiskName(d.name))

Type guard

function isNamedDisk(d) { return d != null && typeof d.name === 'string' && d.name.length > 0 && /^[A-Za-z0-9_-]+$/.test(d.name) }

Try / catch

try { await limactl(['template','validate', file]) } catch (e) { const m = e.message.match(/additionalDisks\[(\d+)\]\.name/); if (m) { renameDisk(+m[1]); } else throw e }

Prevention

When it happens

Trigger: Validate() is called (create/start/edit/restart/apply/template validate/templateArgs) with lima.yaml containing an additionalDisks entry whose `name` is empty, contains invalid characters, or is otherwise not an accepted identifier.

Common situations: Referencing an additional disk created via `limactl disk create` but mistyping its name; leaving `name:` blank; using names with slashes/spaces from copied YAML.

Related errors


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