{"record":{"id":"4e183717390cfcf3","repo":"lima-vm/lima","slug":"field-s-guest-must-be-an-absolute-path-but-is","errorCode":null,"errorMessage":"field `%s.guest` must be an absolute path, but is %#q","messagePattern":"field `(.+?)\\.guest` must be an absolute path, but is %#q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/limayaml/validate.go","lineNumber":394,"sourceCode":"\t\tswitch rule.Proto {\n\t\tcase limatype.ProtoTCP, limatype.ProtoUDP, limatype.ProtoAny:\n\t\tdefault:\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.proto` must be %#q, %#q, or %#q\", field, limatype.ProtoTCP, limatype.ProtoUDP, limatype.ProtoAny))\n\t\t}\n\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}","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/limayaml/validate.go#L376-L412","documentation":"Validate() requires CopyToHost rules to use an absolute guest-side path: if GuestFile is non-empty it must satisfy path.IsAbs() (POSIX semantics, validate.go:393-395). CopyToHost copies files from inside the VM to the host, so the guest path is interpreted in the guest filesystem and must be fully qualified (e.g. /etc/hosts).","triggerScenarios":"limayaml.Validate() (via limactl validate/edit/start/restart/clone/rename/template tooling) sees CopyToHost[i].GuestFile set to a relative path like \"etc/hosts\" or \"~/notes\".","commonSituations":"Hand-writing a copyToHost rule with a relative path; assuming ~ expansion applies on the guest side; copying host-style paths into the guest field.","solutions":["Prefix the guest path with \"/\" — use a fully qualified path like /etc/hosts.","Do not use ~ or environment variables for GuestFile; the guest path must be literal and absolute.","Run `limactl validate <file>` to catch path issues before starting the instance."],"exampleFix":"# before\ncopyToHost:\n  - guest: etc/hosts\n    host: /tmp/hosts\n# after\ncopyToHost:\n  - guest: /etc/hosts\n    host: /tmp/hosts","handlingStrategy":"validation","validationCode":"for i, r := range cfg.CopyToHost {\n    if r.GuestFile != \"\" && !strings.HasPrefix(r.GuestFile, \"/\") {\n        return fmt.Errorf(\"CopyToHost[%d].guest must be absolute: %q\", i, r.GuestFile)\n    }\n}","typeGuard":"func absGuestPath(p string) bool { return p != \"\" && path.IsAbs(p) }","tryCatchPattern":"if err := limayaml.Validate(y, \"strict\"); err != nil {\n    return fmt.Errorf(\"copyToHost guest path must start with /: %w\", err)\n}","preventionTips":["Write guest paths as full POSIX paths (/etc/...), never relative or ~.","No tilde or env-var expansion happens on guest paths — literalize them.","Add limactl validate to pre-start checks."],"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"}