{"record":{"id":"06871247baca75d8","repo":"hashicorp/nomad","slug":"path-was-not-relative-to-the-mount-task-path","errorCode":null,"errorMessage":"path was not relative to the mount task path","messagePattern":"path was not relative to the mount task path","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/shared/executor/executor_linux_cgo.go","lineNumber":1077,"sourceCode":"\t// Turn relative-to-taskdir path into re-rooted absolute path to avoid\n\t// libcontainer trying to resolve the binary using $PATH.\n\t// Do *not* use filepath.Join as it will translate \"..\"s returned by\n\t// filepath.Rel. Prepending \"/\" will cause the path to be rooted in the\n\t// chroot which is the desired behavior.\n\treturn filepath.Clean(\"/\" + rel), hostPath, nil\n}\n\n// getPathInMount for the binary in the mount's host path, constructing the path\n// considering that the bin path is rooted in the mount's task path and not its\n// host path. It returns the absolute path rooted inside the container and the\n// absolute path on the host.\nfunc getPathInMount(mountHostPath, mountTaskPath, bin string) (string, string, error) {\n\n\t// Find the path relative to the mount point in the task so that we can\n\t// trim off any shared prefix when we search on the host path\n\tmountRel, err := filepath.Rel(mountTaskPath, bin)\n\tif mountRel == \"\" || err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"path was not relative to the mount task path\")\n\t}\n\n\thostPath := filepath.Join(mountHostPath, mountRel)\n\n\terr = filepathIsRegular(hostPath)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\t// Turn relative-to-taskdir path into re-rooted absolute path to avoid\n\t// libcontainer trying to resolve the binary using $PATH.\n\t// Do *not* use filepath.Join as it will translate \"..\"s returned by\n\t// filepath.Rel. Prepending \"/\" will cause the path to be rooted in the\n\t// chroot which is the desired behavior.\n\treturn filepath.Clean(\"/\" + bin), hostPath, nil\n}\n\n// filepathIsRegular verifies that a filepath is a regular file (i.e. not a","sourceCodeStart":1059,"sourceCodeEnd":1095,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/shared/executor/executor_linux_cgo.go#L1059-L1095","documentation":"getPathInMount resolves a binary located under a mount by relating the bin path to the mount's task-side path. If filepath.Rel(mountTaskPath, bin) fails or is empty, the bin was not under the mount's task path and this error is thrown.","triggerScenarios":"lookupTaskBin iterates task mounts; for each mount whose task path should prefix the bin, if bin is not beneath mountTaskPath (or paths are inconsistent), this error is returned for that mount.","commonSituations":"Binary lives outside the mount being searched; mount task path configured differently between host and task views (custom CSI/host volume mounts); typo'd mount definitions in the driver config; path casing/trailing-slash inconsistencies.","solutions":["Ensure the command binary resides under the declared mount's task path","Fix the mount definitions (task path vs host path) in the job/driver config","Verify paths are clean/absolute and consistently formatted","Check host volume/CSI mount options so the mount actually contains the binary"],"exampleFix":"// before\ncommand = \"/opt/bin/app\"  # not under mounted local/\nmounts = [{ task_path = \"local\", host_path = \"/srv/share\" }]\n// after\ncommand = \"local/app\"  # or place binary inside the mount","handlingStrategy":"validation","validationCode":"if !strings.HasPrefix(bin, mount.TaskPath) {\n    return fmt.Errorf(\"bin %q not under mount task path %q\", bin, mount.TaskPath)\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"not relative to the mount task path\") {\n    // bin lives outside this mount; adjust mounts or command path\n    return fmt.Errorf(\"mount/command mismatch: %w\", err)\n}","preventionTips":["Place the command binary inside a declared mount's task path","Keep mount task_path and host_path definitions consistent","Clean and absolutize both paths before comparison"],"tags":["path-resolution","mounts","executor"],"backgroundTag":"relative-path-resolution-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}