{"record":{"id":"2d044dfa4dccca28","repo":"hashicorp/nomad","slug":"failed-to-change-directory-permissions-for-the-all","errorCode":null,"errorMessage":"failed to change directory permissions for the AllocDir: %v","messagePattern":"failed to change directory permissions for the AllocDir: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"client/client.go","lineNumber":759,"sourceCode":"\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\n\t\t// agent package, but don't risk a panic just for a long line.\n\t\treserved = conf.Node.ReservedResources.Networks.ReservedHostPorts\n\t}\n\tc.logger.Info(\"using dynamic ports\",\n\t\t\"min\", conf.MinDynamicPort,","sourceCodeStart":741,"sourceCodeEnd":777,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/client.go#L741-L777","documentation":"For the temp-based alloc dir, the client changes permissions with os.Chmod(p, 0o711) so the execute bit is present for traversal. If the chmod fails, init aborts with this error. Without the execute bit, task drivers cannot traverse the alloc directory.","triggerScenarios":"client init without alloc_dir configured: os.Chmod(tempAllocDir, 0o711) returns error right after MkdirTemp/EvalSymlinks.","commonSituations":"Filesystem that does not support chmod (some network/CIFS/NFS mounts, certain fuse mounts), or ownership of the temp dir unexpectedly changed between creation and chmod (external cleaner/tampering).","solutions":["Place the alloc dir (or TMPDIR) on a local POSIX filesystem that supports permission changes instead of NFS/CIFS/fuse.","Check the wrapped error (EPERM typically) and ensure the process user owns the directory.","Configure an explicit alloc_dir on supported storage to skip the temp-dir/chmod path."],"exampleFix":"// before: TMPDIR on CIFS mount\nEnvironment=TMPDIR=/mnt/cifs/tmp\n// after\nclient { alloc_dir = \"/var/lib/nomad/alloc\" }  # local ext4 volume","handlingStrategy":"validation","validationCode":"d, err := os.MkdirTemp(os.TempDir(), \"NomadClientProbe\")\nif err != nil { return err }\nif err := os.Chmod(d, 0o711); err != nil {\n    os.Remove(d)\n    return fmt.Errorf(\"temp filesystem %q does not support chmod: %v\", os.TempDir(), err)\n}\nos.Remove(d)","typeGuard":null,"tryCatchPattern":"if err := clientInit(); err != nil {\n    if strings.Contains(err.Error(), \"failed to change directory permissions for the AllocDir\") {\n        // move TMPDIR/alloc_dir to a local POSIX filesystem\n    }\n}","preventionTips":["Avoid NFS/CIFS/fuse mounts for TMPDIR or alloc_dir","Run Nomad as a user that owns its data directories","Smoke-test chmod support on the chosen filesystem before rollout"],"tags":["client-init","permissions","chmod","filesystem"],"backgroundTag":"chmod-permission-denied","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"}