{"record":{"id":"e54829a5fe8b4ed6","repo":"hashicorp/nomad","slug":"no-file-or-directory-at-s","errorCode":null,"errorMessage":"No file or directory at %s","messagePattern":"No file or directory at (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/fmt.go","lineNumber":175,"sourceCode":"\t\treturn 1\n\t}\n\n\tif !f.checkSuccess {\n\t\treturn 1\n\t}\n\treturn 0\n}\n\nfunc (f *FormatCommand) fmt() {\n\tif len(f.paths) == 0 {\n\t\tf.processFile(stdinPath, f.stdin)\n\t\treturn\n\t}\n\n\tfor _, path := range f.paths {\n\t\tinfo, err := os.Stat(path)\n\t\tif err != nil {\n\t\t\tf.appendError(fmt.Errorf(\"No file or directory at %s\", path))\n\t\t\tcontinue\n\t\t}\n\n\t\tif info.IsDir() {\n\t\t\tf.processDir(path)\n\t\t} else {\n\t\t\tif isNomadFile(info) {\n\t\t\t\tfp, err := os.Open(path)\n\t\t\t\tif err != nil {\n\t\t\t\t\tf.appendError(fmt.Errorf(\"Failed to open file %s: %w\", path, err))\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tf.processFile(path, fp)\n\n\t\t\t\tfp.Close()\n\t\t\t} else {\n\t\t\t\tf.appendError(fmt.Errorf(\"Only .nomad and .hcl files can be processed using nomad fmt\"))","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/fmt.go#L157-L193","documentation":"The `nomad fmt` command (HCL formatter) stats each supplied path. If os.Stat fails — the file/directory does not exist or is inaccessible — it records \"No file or directory at %s\" via appendError and continues to the next path.","triggerScenarios":"Running `nomad fmt <path>` where path was deleted, mis-typed, is a broken symlink, or the cwd differs from what the caller assumed.","commonSituations":"Typos in filenames; running fmt from a different directory in scripts; variables expanding to empty so the path becomes invalid; broken symlinks left by tooling.","solutions":["Verify the path exists with ls before running fmt","Run fmt from the correct working directory or use absolute paths","Check shell variables that build the path (an empty variable yields a bad path)"],"exampleFix":"// before\nnomad fmt ./jobs/task.hcl   # typo: file is tasks.hcl\n// after\nls ./jobs/\nnomad fmt ./jobs/tasks.hcl","handlingStrategy":"validation","validationCode":"info, err := os.Stat(path)\nif err != nil {\n    return fmt.Errorf(\"path %q does not exist: %w\", path, err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify paths with ls/test -e before running fmt","Use absolute paths in scripts","Check cwd assumptions and empty shell variables that form paths"],"tags":["cli","filesystem","fmt"],"backgroundTag":"file-not-found","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"}