{"record":{"id":"4753fd27454690f9","repo":"lima-vm/lima","slug":"field-s-host-must-be-an-absolute-path-but-is","errorCode":null,"errorMessage":"field `%s.host` must be an absolute path, but is %#q","messagePattern":"field `(.+?)\\.host` must be an absolute path, but is %#q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/limayaml/validate.go","lineNumber":399,"sourceCode":"\t\tif rule.Reverse && rule.GuestSocket == \"\" {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.reverse` must be %t\", field, false))\n\t\t}\n\t\tif rule.Reverse && rule.HostSocket == \"\" {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.reverse` must be %t\", field, false))\n\t\t}\n\t\t// Not validating that the various GuestPortRanges and HostPortRanges are not overlapping. Rules will be\n\t\t// processed sequentially and the first matching rule for a guest port determines forwarding behavior.\n\t}\n\tfor i, rule := range y.CopyToHost {\n\t\tfield := fmt.Sprintf(\"CopyToHost[%d]\", i)\n\t\tif rule.GuestFile != \"\" {\n\t\t\tif !path.IsAbs(rule.GuestFile) {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.guest` must be an absolute path, but is %#q\", field, rule.GuestFile))\n\t\t\t}\n\t\t}\n\t\tif rule.HostFile != \"\" {\n\t\t\tif !filepath.IsAbs(rule.HostFile) {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.host` must be an absolute path, but is %#q\", field, rule.HostFile))\n\t\t\t}\n\t\t}\n\t}\n\n\tif y.VMType != nil && *y.VMType == limatype.HCS {\n\t\tif y.HostResolver.Enabled != nil && *y.HostResolver.Enabled && len(y.DNS) > 0 {\n\t\t\terrs = errors.Join(errs, errors.New(\"field `dns` must be empty when field `HostResolver.Enabled` is true\"))\n\t\t}\n\t} else {\n\t\tif HostResolverEnabled(y) && len(y.DNS) > 0 {\n\t\t\terrs = errors.Join(errs, errors.New(\"field `dns` must be empty when field `HostResolver.Enabled` is true\"))\n\t\t}\n\t}\n\n\terr := validateNetwork(y)\n\tif err != nil {\n\t\terrs = errors.Join(errs, err)\n\t}","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/limayaml/validate.go#L381-L417","documentation":"Validate() requires CopyToHost rules to use an absolute host-side path: if HostFile is non-empty it must satisfy filepath.IsAbs() (host OS semantics, validate.go:398-400). The destination on the host machine must be a fully qualified path so the copy target is unambiguous.","triggerScenarios":"limayaml.Validate() (via limactl validate/edit/start/restart/clone/rename/template tooling) sees CopyToHost[i].HostFile set to a relative path like \"out.txt\" or \"./tmp/x\".","commonSituations":"Writing `host: ~/copy.txt` expecting shell tilde expansion; template reuse across machines where a relative destination seemed convenient; programmatically generated rules defaulting to relative output names.","solutions":["Use an absolute host path (e.g. /home/user/copy.txt); expand ~ yourself in the template.","On the host side, filepath.IsAbs is platform-specific — on Windows use a drive-qualified path (C:\\...).","Pre-validate with `limactl validate` before limactl start."],"exampleFix":"# before\ncopyToHost:\n  - guest: /var/log/app.log\n    host: logs/app.log\n# after\ncopyToHost:\n  - guest: /var/log/app.log\n    host: /home/me/logs/app.log","handlingStrategy":"validation","validationCode":"for i, r := range cfg.CopyToHost {\n    if r.HostFile != \"\" && !filepath.IsAbs(r.HostFile) {\n        return fmt.Errorf(\"CopyToHost[%d].host must be absolute: %q\", i, r.HostFile)\n    }\n}","typeGuard":"func absHostPath(p string) bool { return p != \"\" && filepath.IsAbs(p) }","tryCatchPattern":"if err := limayaml.Validate(y, \"strict\"); err != nil {\n    return fmt.Errorf(\"copyToHost host path must be absolute: %w\", err)\n}","preventionTips":["Expand ~ and env vars yourself before putting the host path in the template.","On Windows use drive-qualified absolute paths.","Generate host destinations from absolute config values, not relative defaults."],"tags":["lima","config-validation","copytohost","paths"],"backgroundTag":"path-must-be-absolute","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}