{"record":{"id":"d25e8a29a8f4ae75","repo":"hashicorp/nomad","slug":"failed-creating-alloc-dir-w","errorCode":null,"errorMessage":"failed creating alloc dir: %w","messagePattern":"failed creating alloc dir: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"client/client.go","lineNumber":743,"sourceCode":"\n\t// Ensure host_volumes_dir config is not empty.\n\tif conf.HostVolumesDir == \"\" {\n\t\tconf = c.UpdateConfig(func(c *config.Config) {\n\t\t\tc.HostVolumesDir = filepath.Join(conf.StateDir, \"host_volumes\")\n\t\t})\n\t}\n\n\t// Ensure the alloc mounts dir exists if we are configured with a custom path.\n\tif conf.AllocMountsDir != \"\" {\n\t\tif err := os.MkdirAll(conf.AllocMountsDir, 0o711); err != nil {\n\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","sourceCodeStart":725,"sourceCodeEnd":761,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/client.go#L725-L761","documentation":"If conf.AllocDir is set to a custom path, the client runs os.MkdirAll(conf.AllocDir, 0o711) during init. Any error aborts client startup with this message. The alloc dir holds working directories for all allocations on the node and must exist before any task starts.","triggerScenarios":"client init with alloc_dir explicitly configured: os.MkdirAll(conf.AllocDir, 0o711) returns error.","commonSituations":"alloc_dir pointing to a path the nomad user cannot create (missing parents, no write access), a file already existing at the path, full or read-only data disk, or container storage driver limits.","solutions":["Pre-create alloc_dir with correct ownership and 0711 permissions for the user running Nomad.","Check the wrapped error (ENOENT/EACCES/ENOSPC/EEXIST-as-file) and correct the path, parent permissions, or disk state.","Point alloc_dir at a dedicated local writable volume reserved for Nomad."],"exampleFix":"// before\nclient { alloc_dir = \"/opt/nomad/alloc\" }  // /opt/nomad owned by root:root 755\n// after\nsudo mkdir -p /opt/nomad/alloc && sudo chown -R nomad:nomad /opt/nomad && sudo chmod 711 /opt/nomad/alloc","handlingStrategy":"validation","validationCode":"func ensureAllocDir(p string) error {\n    if fi, err := os.Stat(p); err == nil && !fi.IsDir() {\n        return fmt.Errorf(\"%s is not a directory\", p)\n    }\n    if err := os.MkdirAll(p, 0o711); err != nil {\n        return err\n    }\n    f, err := os.CreateTemp(p, \".writetest\")\n    if err != nil { return err }\n    f.Close(); os.Remove(f.Name())\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := clientInit(); err != nil {\n    var pe *fs.PathError\n    if errors.As(err, &pe) && strings.Contains(err.Error(), \"failed creating alloc dir\") {\n        log.Printf(\"cannot create alloc dir %s: %v\", pe.Path, pe.Err)\n    }\n}","preventionTips":["Pre-create alloc_dir and chown it to the user running Nomad","Dedicate a local volume with sufficient space to alloc_dir","Confirm nothing (file, mount) occupies the alloc_dir path","Provision infrastructure with configuration management (mkdir + chown) before agent start"],"tags":["client-init","filesystem","permissions","directory"],"backgroundTag":"mkdir-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"}