lima-vm/lima · error

field `mounts[%d].location` must be an absolute path, got %#

Error message

field `mounts[%d].location` must be an absolute path, got %#q

What it means

A mount location is a relative path. Mount locations must be absolute host paths so they can be resolved unambiguously by the host and guest agents.

Source

Thrown at pkg/limayaml/validate.go:126

	}

	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))
			}
			if warn {
				logrus.Warnf("field `mounts[%d].location` refers to a non-existent directory: %#q:", i, f.Location)
			}
		} else if !st.IsDir() {
			errs = errors.Join(errs, fmt.Errorf("field `mounts[%d].location` refers to a non-directory path: %#q: %w", i, f.Location, err))
		}

View on GitHub (pinned to dd909d0973)

Solutions

  1. Change the location to an absolute path, e.g. `/home/me/data`
  2. Or use `~`-prefixed form, e.g. `~/projects/data`, which is expanded later
  3. Validate with `limactl template validate` after fixing

Example fix

// before
mounts:
  - location: ./data
// after
mounts:
  - location: ~/data
Defensive patterns

Strategy: validation

Validate before calling

function validMountLocation(loc) { return typeof loc === 'string' && (loc.startsWith('/') || loc.startsWith('~')) }

Type guard

function isAbsoluteOrHomePath(p) { return typeof p === 'string' && (p.startsWith('/') || p.startsWith('~/')) }

Try / catch

try { await limactl(['template','validate', file]) } catch (e) { if (/mounts\[\d+\]\.location.*absolute path/.test(e.message)) { absolutizeMounts(); } else throw e }

Prevention

When it happens

Trigger: A mount location like `./data` or `data` is present in lima.yaml when Validate runs (create/start/edit/restart/apply/template validate).

Common situations: Writing `mounts: [{location: ./data}]` copied from other tools; assuming CWD-relative paths work; template files shared across users with different layouts.

Related errors


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