{"record":{"id":"3f37de3ce3cdd4d5","repo":"hashicorp/nomad","slug":"failed-to-find-temporary-directory-for-the-allocdi","errorCode":null,"errorMessage":"failed to find temporary directory for the AllocDir: %v","messagePattern":"failed to find temporary directory for the AllocDir: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"client/client.go","lineNumber":754,"sourceCode":"\t\t\treturn fmt.Errorf(\"failed creating alloc mounts dir: %w\", err)\n\t\t}\n\t}\n\n\t// Ensure the alloc dir exists if we are configured with a custom path.\n\tif conf.AllocDir != \"\" {\n\t\tif err := os.MkdirAll(conf.AllocDir, 0o711); err != nil {\n\t\t\treturn fmt.Errorf(\"failed creating alloc dir: %w\", err)\n\t\t}\n\t} else {\n\t\t// Otherwise make a temp directory to use.\n\t\tp, err := os.MkdirTemp(\"\", \"NomadClient\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed creating temporary directory for the AllocDir: %v\", err)\n\t\t}\n\n\t\tp, err = filepath.EvalSymlinks(p)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to find temporary directory for the AllocDir: %v\", err)\n\t\t}\n\n\t\t// Change the permissions to have the execute bit\n\t\tif err := os.Chmod(p, 0o711); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to change directory permissions for the AllocDir: %v\", err)\n\t\t}\n\n\t\tconf = c.UpdateConfig(func(c *config.Config) {\n\t\t\tc.AllocDir = p\n\t\t\tc.AllocMountsDir = p\n\t\t})\n\t}\n\n\tc.logger.Info(\"using alloc directory\", \"alloc_dir\", conf.AllocDir)\n\n\treserved := \"<none>\"\n\tif conf.Node != nil && conf.Node.ReservedResources != nil {\n\t\t// Node should always be non-nil due to initialization in the","sourceCodeStart":736,"sourceCodeEnd":772,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/client.go#L736-L772","documentation":"Immediately after creating the temporary alloc dir, the client resolves it with filepath.EvalSymlinks to get the canonical path. If resolution fails (the path cannot be resolved through the filesystem), init aborts with this error.","triggerScenarios":"client init without alloc_dir configured: os.MkdirTemp succeeds but filepath.EvalSymlinks(p) on the new NomadClient temp dir returns error.","commonSituations":"Temp root on symlinked/overlay filesystems where resolution races or fails, sandboxed environments (rare), or TMPDIR containing broken symlink components.","solutions":["Inspect the wrapped OS error to identify which path component failed resolution and fix it (usually a broken TMPDIR symlink).","Ensure TMPDIR points to a real directory path without broken symlink components.","Set an explicit alloc_dir in client config to bypass temporary directory creation entirely."],"exampleFix":"// before\nsudo ln -sfn /mnt/removed-vol /var/tmp/nomadtmp; TMPDIR=/var/tmp/nomadtmp nomad agent -client\n// after\nrm /var/tmp/nomadtmp && mkdir -p /var/tmp/nomadtmp\n# or\nclient { alloc_dir = \"/var/lib/nomad/alloc\" }","handlingStrategy":"validation","validationCode":"tmp := os.TempDir()\nresolved, err := filepath.EvalSymlinks(tmp)\nif err != nil {\n    return fmt.Errorf(\"TMPDIR %q cannot be resolved: %v\", tmp, err)\n}\n_ = resolved","typeGuard":null,"tryCatchPattern":"if err := clientInit(); err != nil {\n    if strings.Contains(err.Error(), \"failed to find temporary directory for the AllocDir\") {\n        // repair TMPDIR symlink chain or switch to explicit alloc_dir\n    }\n}","preventionTips":["Keep TMPDIR free of broken symlink components","Test temp dir resolution after storage/infra changes","Set explicit alloc_dir to bypass temp path handling"],"tags":["client-init","temp-directory","symlink"],"backgroundTag":"temp-dir-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"}