{"record":{"id":"56fc03813c4a7801","repo":"hashicorp/nomad","slug":"work-dir-must-be-an-absolute-path-s","errorCode":null,"errorMessage":"work_dir must be an absolute path: %s","messagePattern":"work_dir must be an absolute path: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/java/driver.go","lineNumber":223,"sourceCode":"\n\tswitch tc.ModeIPC {\n\tcase \"\", executor.IsolationModePrivate, executor.IsolationModeHost:\n\tdefault:\n\t\treturn fmt.Errorf(\"ipc_mode must be %q or %q, got %q\", executor.IsolationModePrivate, executor.IsolationModeHost, tc.ModeIPC)\n\t}\n\n\tsupported := capabilities.Supported()\n\tbadAdds := supported.Difference(capabilities.New(tc.CapAdd))\n\tif !badAdds.Empty() {\n\t\treturn fmt.Errorf(\"cap_add configured with capabilities not supported by system: %s\", badAdds)\n\t}\n\tbadDrops := supported.Difference(capabilities.New(tc.CapDrop))\n\tif !badDrops.Empty() {\n\t\treturn fmt.Errorf(\"cap_drop configured with capabilities not supported by system: %s\", badDrops)\n\t}\n\n\tif tc.WorkDir != \"\" && !filepath.IsAbs(tc.WorkDir) {\n\t\treturn fmt.Errorf(\"work_dir must be an absolute path: %s\", tc.WorkDir)\n\t}\n\treturn nil\n}\n\n// TaskState is the state which is encoded in the handle returned in\n// StartTask. This information is needed to rebuild the taskConfig state and handler\n// during recovery.\ntype TaskState struct {\n\tReattachConfig *pstructs.ReattachConfig\n\tTaskConfig     *drivers.TaskConfig\n\tPid            int\n\tStartedAt      time.Time\n}\n\n// Driver is a driver for running images via Java\ntype Driver struct {\n\t// eventer is used to handle multiplexing of TaskEvents calls such that an\n\t// event can be broadcast to all callers","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/java/driver.go#L205-L241","documentation":"This error is thrown by the Nomad Java driver's validate() when the work_dir config field is set to a relative path. The working directory for the Java task must be an absolute path (checked with filepath.IsAbs), because the executor needs an unambiguous filesystem location independent of where the executor process starts. Empty work_dir is allowed (the task's default directory is used).","triggerScenarios":"Setting work_dir = \"app/work\" or \"./bin\" (no leading slash) in a Java task's driver config, then starting the task.","commonSituations":"Configs copied from Windows/Unix or written assuming a default base directory; templated configs where a path prefix variable is empty; users confusing work_dir with the task directory which is relative.","solutions":["Prefix the path with '/' to make it absolute, e.g. /opt/app/work","Use the task's directory (NomadEnvTaskDir/alloc dir) instead of leaving a relative work_dir","Remove work_dir entirely if the default task directory is acceptable","Fix empty template variables that were supposed to supply the absolute prefix"],"exampleFix":"// before\n-work_dir = \"app/workdir\"\n// after\n-work_dir = \"/opt/app/workdir\"","handlingStrategy":"validation","validationCode":"func checkWorkDir(wd string) error {\n    if wd != \"\" && !filepath.IsAbs(wd) {\n        return fmt.Errorf(\"work_dir must be an absolute path: %s\", wd)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always build work_dir from absolute prefixes (NOMAD_TASK_DIR, /opt/...)","Templatize paths with variables but assert the rendered value starts with '/'","Prefer omitting work_dir to rely on the task directory","Add job-spec linting that rejects relative driver paths"],"tags":["nomad","java-driver","path-validation","config"],"backgroundTag":"path-must-be-absolute","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"}