{"record":{"id":"d9541b2551301d7c","repo":"lima-vm/lima","slug":"field-s-guestsocket-must-be-an-absolute-path-b","errorCode":null,"errorMessage":"field `%s.guestSocket` must be an absolute path, but is %#q","messagePattern":"field `(.+?)\\.guestSocket` must be an absolute path, but is %#q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/limayaml/validate.go","lineNumber":354,"sourceCode":"\t\tfor j := range 2 {\n\t\t\tif err := validatePort(fmt.Sprintf(\"%s.guestPortRange[%d]\", field, j), rule.GuestPortRange[j]); err != nil {\n\t\t\t\terrs = errors.Join(errs, err)\n\t\t\t}\n\t\t\tif rule.HostSocket == \"\" {\n\t\t\t\tif err := validatePort(fmt.Sprintf(\"%s.hostPortRange[%d]\", field, j), rule.HostPortRange[j]); err != nil {\n\t\t\t\t\terrs = errors.Join(errs, err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif rule.GuestPortRange[0] > rule.GuestPortRange[1] {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.guestPortRange[1]` must be greater than or equal to field `%s.guestPortRange[0]`\", field, field))\n\t\t}\n\t\tif rule.HostPortRange[0] > rule.HostPortRange[1] {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.hostPortRange[1]` must be greater than or equal to field `%s.hostPortRange[0]`\", field, field))\n\t\t}\n\t\tif rule.GuestSocket != \"\" {\n\t\t\tif !path.IsAbs(rule.GuestSocket) {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.guestSocket` must be an absolute path, but is %#q\", field, rule.GuestSocket))\n\t\t\t}\n\t\t\tif rule.HostSocket == \"\" && rule.HostPortRange[1]-rule.HostPortRange[0] > 0 {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.guestSocket` can only be mapped to a single port or socket. not a range\", field))\n\t\t\t}\n\t\t}\n\t\tif rule.HostSocket != \"\" {\n\t\t\tif !filepath.IsAbs(rule.HostSocket) {\n\t\t\t\t// should be unreachable because FillDefault() will prepend the instance directory to relative names\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.hostSocket` must be an absolute path, but is %#q\", field, rule.HostSocket))\n\t\t\t}\n\t\t\tif rule.GuestSocket == \"\" && rule.GuestPortRange[1]-rule.GuestPortRange[0] > 0 {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.hostSocket` can only be mapped from a single port or socket. not a range\", field))\n\t\t\t}\n\t\t} else if rule.GuestPortRange[1]-rule.GuestPortRange[0] != rule.HostPortRange[1]-rule.HostPortRange[0] {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.hostPortRange` must specify the same number of ports as field `%s.guestPortRange`\", field, field))\n\t\t}\n\n\t\tif len(rule.HostSocket) >= osutil.UnixPathMax {","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/limayaml/validate.go#L336-L372","documentation":"When a portForward rule uses guestSocket, the path is interpreted inside the guest filesystem and must be absolute (checked with path.IsAbs). A relative path like \"tmp/app.sock\" is ambiguous and rejected.","triggerScenarios":"Validate on a LimaYAML where portForwards[i].GuestSocket is a non-empty string not starting with '/' (e.g. \"tmp/sock\" or \"~/app.sock\").","commonSituations":"Writing a guest socket path relative to home directory using ~; copying a Windows-style or relative path into the config; forgetting the leading slash when refactoring from port to socket forwarding.","solutions":["Prefix the guestSocket value with '/' to make it an absolute guest path","Expand ~ to the absolute guest home path manually (Lima does not expand it)","Verify with `limactl template validate`"],"exampleFix":"// before\nportForwards:\n  - guestSocket: tmp/app.sock\n    hostSocket: /tmp/app.sock\n// after\nportForwards:\n  - guestSocket: /tmp/app.sock\n    hostSocket: /tmp/app.sock","handlingStrategy":"validation","validationCode":"for i, rule := range y.PortForwards {\n  if rule.GuestSocket != \"\" && !strings.HasPrefix(rule.GuestSocket, \"/\") {\n    return fmt.Errorf(\"portForwards[%d]: guestSocket must be an absolute guest path\", i)\n  }\n}","typeGuard":"func guestSocketAbsolute(p string) bool { return p == \"\" || path.IsAbs(p) }","tryCatchPattern":"if err := limayaml.Validate(y, false); err != nil {\n  if strings.Contains(err.Error(), \"guestSocket` must be an absolute path\") {\n    // prepend '/' or expand the path\n  }\n}","preventionTips":["Always start guestSocket with '/'","Expand ~ yourself before writing the config","Remember guestSocket is a guest-filesystem path, not a host path"],"tags":["lima","port-forwarding","unix-socket","config-validation"],"backgroundTag":"socket-path-not-absolute","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}