{"record":{"id":"cc87cb0a206fc081","repo":"hashicorp/nomad","slug":"failed-to-determine-relative-path-base-q-target","errorCode":null,"errorMessage":"failed to determine relative path base=%q target=%q: %v","messagePattern":"failed to determine relative path base=%q target=%q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/shared/executor/executor_linux_cgo.go","lineNumber":1054,"sourceCode":"\n\treturn \"\", \"\", fmt.Errorf(\"file %s not found under path\", bin)\n}\n\n// getPathInTaskDir searches for the binary in the task directory and nested\n// search directory. It returns the absolute path rooted inside the container\n// and the absolute path on the host.\nfunc getPathInTaskDir(taskDir, searchDir, bin string) (string, string, error) {\n\n\thostPath := filepath.Join(searchDir, bin)\n\terr := filepathIsRegular(hostPath)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\t// Find the path relative to the task directory\n\trel, err := filepath.Rel(taskDir, hostPath)\n\tif rel == \"\" || err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\n\t\t\t\"failed to determine relative path base=%q target=%q: %v\",\n\t\t\ttaskDir, hostPath, 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(\"/\" + 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","sourceCodeStart":1036,"sourceCodeEnd":1072,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/shared/executor/executor_linux_cgo.go#L1036-L1072","documentation":"getPathInTaskDir computes the located binary's path relative to the task dir so it can be re-rooted inside the container. If filepath.Rel cannot produce a relative path (e.g. the host path is not under taskDir, or taskDir/hostPath are malformed), this error is thrown, wrapping the Rel error.","triggerScenarios":"getPathInTaskDir found the binary (hostPath valid) but filepath.Rel(taskDir, hostPath) returned an error or empty string — typically when hostPath is absolute on a different root than taskDir or taskDir is empty/not absolute.","commonSituations":"Driver or plugin supplying a non-clean or relative TaskDir; custom drivers extending executor with mismatched task dir and mount paths; symlinks resolving outside the task dir causing path mismatch; Nomad version/config producing empty TaskDir in a custom invocation.","solutions":["Ensure command.TaskDir is an absolute, clean path before calling Launch","Verify the binary's host path is actually beneath the task dir (no unexpected symlinks escaping it)","Check custom driver/plugin code that constructs taskDir/hostPath for consistency","Update Nomad client if a known path-resolution bug was fixed in a later release"],"exampleFix":"// before\ntaskDir := \"alloc/1234/app\"            // relative\ntaskPath, hostPath, err := lookup(taskDir, ...)\n// after\ntaskDir, _ := filepath.Abs(\"alloc/1234/app\")\ntaskDir = filepath.Clean(taskDir)","handlingStrategy":"validation","validationCode":"taskDir := filepath.Clean(task.TaskDir)\nif !filepath.IsAbs(taskDir) {\n    return fmt.Errorf(\"taskDir must be absolute, got %q\", taskDir)\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"failed to determine relative path\") {\n    // log base/target from error text; fix driver's taskDir construction\n    return fmt.Errorf(\"taskdir/hostpath mismatch: %w\", err)\n}","preventionTips":["Always pass absolute, cleaned task dirs into the executor","Avoid symlinks that escape the task dir for binaries","Keep custom drivers' taskDir and host path construction consistent"],"tags":["path-resolution","executor","task-dir"],"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"}