hashicorp/nomad · error
No file or directory at %s
Error message
No file or directory at %s
What it means
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.
Source
Thrown at command/fmt.go:175
return 1
}
if !f.checkSuccess {
return 1
}
return 0
}
func (f *FormatCommand) fmt() {
if len(f.paths) == 0 {
f.processFile(stdinPath, f.stdin)
return
}
for _, path := range f.paths {
info, err := os.Stat(path)
if err != nil {
f.appendError(fmt.Errorf("No file or directory at %s", path))
continue
}
if info.IsDir() {
f.processDir(path)
} else {
if isNomadFile(info) {
fp, err := os.Open(path)
if err != nil {
f.appendError(fmt.Errorf("Failed to open file %s: %w", path, err))
continue
}
f.processFile(path, fp)
fp.Close()
} else {
f.appendError(fmt.Errorf("Only .nomad and .hcl files can be processed using nomad fmt"))View on GitHub (pinned to 482b49bf1a)
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)
Example fix
// before nomad fmt ./jobs/task.hcl # typo: file is tasks.hcl // after ls ./jobs/ nomad fmt ./jobs/tasks.hcl
Defensive patterns
Strategy: validation
Validate before calling
info, err := os.Stat(path)
if err != nil {
return fmt.Errorf("path %q does not exist: %w", path, err)
} Prevention
- Verify paths with ls/test -e before running fmt
- Use absolute paths in scripts
- Check cwd assumptions and empty shell variables that form paths
When it happens
Trigger: Running `nomad fmt <path>` where path was deleted, mis-typed, is a broken symlink, or the cwd differs from what the caller assumed.
Common situations: 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.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Failed to open file %s: %w
- Only .nomad and .hcl files can be processed using nomad fmt
- Failed to list directory %s
- unable to read rooted allocation directory
- plugin not found
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/e54829a5fe8b4ed6.
Report an issue: GitHub.