{"record":{"id":"1aefe02467a2c8cf","repo":"lima-vm/lima","slug":"field-mounts-d-location-must-be-an-absolute-pa","errorCode":null,"errorMessage":"field `mounts[%d].location` must be an absolute path, got %#q","messagePattern":"field `mounts\\[(.+?)\\]\\.location` must be an absolute path, got %#q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/limayaml/validate.go","lineNumber":126,"sourceCode":"\t}\n\n\tif _, err := units.RAMInBytes(*y.Memory); err != nil {\n\t\terrs = errors.Join(errs, fmt.Errorf(\"field `memory` has an invalid value: %w\", err))\n\t}\n\n\tif _, err := units.RAMInBytes(*y.Disk); err != nil {\n\t\terrs = errors.Join(errs, fmt.Errorf(\"field `disk` has an invalid value: %w\", err))\n\t}\n\n\tfor i, disk := range y.AdditionalDisks {\n\t\tif err := identifiers.Validate(disk.Name); err != nil {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `additionalDisks[%d].name is invalid`: %w\", i, err))\n\t\t}\n\t}\n\n\tfor i, f := range y.Mounts {\n\t\tif !filepath.IsAbs(f.Location) && !strings.HasPrefix(f.Location, \"~\") {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `mounts[%d].location` must be an absolute path, got %#q\",\n\t\t\t\ti, f.Location))\n\t\t}\n\t\t// f.Location has already been expanded in FillDefaults(), but that function cannot return errors.\n\t\tloc, err := localpathutil.Expand(f.Location)\n\t\tif err != nil {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `mounts[%d].location` refers to an unexpandable path: %#q: %w\", i, f.Location, err))\n\t\t}\n\t\tst, err := os.Stat(loc)\n\t\tif err != nil {\n\t\t\tif !errors.Is(err, os.ErrNotExist) {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `mounts[%d].location` refers to an inaccessible path: %#q: %w\", i, f.Location, err))\n\t\t\t}\n\t\t\tif warn {\n\t\t\t\tlogrus.Warnf(\"field `mounts[%d].location` refers to a non-existent directory: %#q:\", i, f.Location)\n\t\t\t}\n\t\t} else if !st.IsDir() {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `mounts[%d].location` refers to a non-directory path: %#q: %w\", i, f.Location, err))\n\t\t}","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/limayaml/validate.go#L108-L144","documentation":"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.","triggerScenarios":"A mount location like `./data` or `data` is present in lima.yaml when Validate runs (create/start/edit/restart/apply/template validate).","commonSituations":"Writing `mounts: [{location: ./data}]` copied from other tools; assuming CWD-relative paths work; template files shared across users with different layouts.","solutions":["Change the location to an absolute path, e.g. `/home/me/data`","Or use `~`-prefixed form, e.g. `~/projects/data`, which is expanded later","Validate with `limactl template validate` after fixing"],"exampleFix":"// before\nmounts:\n  - location: ./data\n// after\nmounts:\n  - location: ~/data","handlingStrategy":"validation","validationCode":"function validMountLocation(loc) { return typeof loc === 'string' && (loc.startsWith('/') || loc.startsWith('~')) }","typeGuard":"function isAbsoluteOrHomePath(p) { return typeof p === 'string' && (p.startsWith('/') || p.startsWith('~/')) }","tryCatchPattern":"try { await limactl(['template','validate', file]) } catch (e) { if (/mounts\\[\\d+\\]\\.location.*absolute path/.test(e.message)) { absolutizeMounts(); } else throw e }","preventionTips":["Never use ./ or bare relative paths in mounts.location","Prefer `~/...` for user files so configs stay portable","Lint lima.yaml with `limactl template validate` in CI"],"tags":["lima","config-validation","mounts","path"],"backgroundTag":"relative-path-not-allowed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}