hashicorp/nomad · error

File %s not found in path %s

Error message

File %s not found in path %s

What it means

FindFileInPath walks the directory tree rooted at p looking for a file whose base name matches the given file name. This error is returned when the walk completed without any walk errors but the file was never encountered — the named file simply does not exist anywhere under p.

Source

Thrown at helper/raftutil/state.go:351

	walkFn := func(walkPath string, info os.FileInfo, err error) error {
		if err != nil {
			return err
		}

		if filepath.Base(walkPath) == file {
			path = walkPath
		}
		return nil
	}

	// Walk path p looking for file
	walkErr := filepath.Walk(p, walkFn)
	if walkErr != nil {
		return "", walkErr
	}

	if path == "" {
		return "", fmt.Errorf("File %s not found in path %s", file, p)
	}

	return path, nil
}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Use FindRaftStore instead of the raft.db-only FindRaftFile/FindFileInPath so WAL (wal/) deployments are also detected.
  2. Confirm the path is the Nomad server data_dir containing server/raft/raft.db: ls <p>/server/raft/raft.db.
  3. If targeting a WAL deployment, pass the wal/ directory directly (FindRaftStore accepts it).
  4. Restore raft.db from backup or take a nomad snapshot if the file was lost.
  5. Double-check you are searching the correct host/volume (e.g. the actual server node, not a standby with an empty dir).

Example fix

// before: only searches for raft.db, fails on WAL deployments
path, err := raftutil.FindFileInPath("raft.db", dataDir)
// after: prefer the backend-aware search
storePath, err := raftutil.FindRaftStore(dataDir)
Defensive patterns

Strategy: fallback

Validate before calling

// confirm a raft.db actually exists under the tree before searching
found := false
filepath.Walk(dataDir, func(p string, info os.FileInfo, err error) error {
    if err == nil && !info.IsDir() && info.Name() == "raft.db" {
        found = true
    }
    return nil
})
if !found { return errors.New("data dir has no raft.db; WAL backend? use FindRaftStore") }

Try / catch

path, err := raftutil.FindFileInPath("raft.db", dataDir)
if err != nil {
    if strings.Contains(err.Error(), "not found in path") {
        // fall back to backend-aware search (handles wal/ too)
        return raftutil.FindRaftStore(dataDir)
    }
    return err
}

Prevention

When it happens

Trigger: FindFileInPath("raft.db", p) (via FindRaftStore or FindRaftFile) on a directory tree that contains no file named raft.db at any depth.

Common situations: Pointing the recovery/inspection tooling at a WAL-backend data dir (which has wal/ but no raft.db); client-only or empty data directories; the raft.db file was deleted or moved; searching the wrong volume/backup mount.

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


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/4217054590a927e6. Report an issue: GitHub.