{"record":{"id":"f87cbcff3ca65b91","repo":"hashicorp/nomad","slug":"path-was-not-a-regular-file","errorCode":null,"errorMessage":"path was not a regular file","messagePattern":"path was not a regular file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/shared/executor/executor_linux_cgo.go","lineNumber":1103,"sourceCode":"\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(\"/\" + bin), hostPath, nil\n}\n\n// filepathIsRegular verifies that a filepath is a regular file (i.e. not a\n// directory, socket, device, etc.)\nfunc filepathIsRegular(path string) error {\n\tf, err := os.Stat(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !f.Mode().Type().IsRegular() {\n\t\treturn fmt.Errorf(\"path was not a regular file\")\n\t}\n\treturn nil\n}\n\nfunc newSetCPUSetCgroupHook(cgroupPath string) runc.Hook {\n\treturn runc.NewFunctionHook(func(state *specs.State) error {\n\t\treturn cgroups.WriteCgroupProc(cgroupPath, state.Pid)\n\t})\n}\n","sourceCodeStart":1085,"sourceCodeEnd":1113,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/shared/executor/executor_linux_cgo.go#L1085-L1113","documentation":"filepathIsRegular stats a candidate binary path and rejects anything that is not a plain regular file. Symbolic links that resolve to directories, sockets, FIFOs, or missing files surface here (stat errors pass through unchanged; this message is returned when the mode is not regular).","triggerScenarios":"getPathInTaskDir or getPathInMount found a file matching the binary name, but os.Stat shows it is a directory, symlink-to-non-file, socket, or other special file instead of a regular executable.","commonSituations":"Artifact extraction created a directory with the binary's name; binary replaced by a symlink chain broken or pointing at a dir; task dir layout changed so the matched name is a folder; tmpfs/odd FS producing device files.","solutions":["Replace the non-regular file at the path with the actual executable binary","Fix artifact/extract settings that produced a directory instead of a file","Check symlink targets resolve to a regular executable file","Verify the path referenced in the job spec points to the file, not its containing directory"],"exampleFix":"// before\nbin/taskName/  <- directory extracted from artifact\n// after\n# correct the destination so the executable itself is at bin/taskName","handlingStrategy":"validation","validationCode":"fi, err := os.Stat(candidateBin)\nif err == nil && !fi.Mode().IsRegular() {\n    return fmt.Errorf(\"%s is not a regular file\", candidateBin)\n}","typeGuard":"func isRegularFile(p string) bool {\n    fi, err := os.Stat(p)\n    return err == nil && fi.Mode().IsRegular()\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"not a regular file\") {\n    return fmt.Errorf(\"binary path points to a non-file (dir/socket?): %w\", err)\n}","preventionTips":["Verify artifact extraction yields a file at the exact command path","Resolve symlinks and confirm targets are regular executables","Stat the resolved binary path in a pre-launch check"],"tags":["filesystem","path-lookup","executor"],"backgroundTag":"not-a-regular-file","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"}