hashicorp/nomad · error

Couldn't read the file information %v: %w

Error message

Couldn't read the file information %v: %w

What it means

While iterating dirEntries from os.ReadDir in embedDirs, each entry's stat info is fetched with fileEntry.Info(). This error wraps that Info() failure. Info() typically fails only if the directory entry was removed or became unreachable between ReadDir and Info (ENOENT), or on I/O error.

Source

Thrown at client/allocdir/task_dir.go:271

		}

		// Create destination directory.
		destDir := filepath.Join(t.Dir, dest)

		if err := createDir(t.Dir, dest); err != nil {
			return fmt.Errorf("Couldn't create destination directory %v: %w", destDir, err)
		}

		// Enumerate the files in source.
		dirEntries, err := os.ReadDir(source)
		if err != nil {
			return fmt.Errorf("Couldn't read directory %v: %w", source, err)
		}

		for _, fileEntry := range dirEntries {
			entry, err := fileEntry.Info()
			if err != nil {
				return fmt.Errorf("Couldn't read the file information %v: %w", entry, err)
			}
			hostEntry := filepath.Join(source, entry.Name())
			taskEntry := filepath.Join(destDir, filepath.Base(hostEntry))
			if entry.IsDir() {
				subdirs[hostEntry] = filepath.Join(dest, filepath.Base(hostEntry))
				continue
			}

			// Check if entry exists. This can happen if restarting a failed
			// task.
			if _, err := os.Lstat(taskEntry); err == nil {
				continue
			}

			if !entry.Mode().IsRegular() {
				// If it is a symlink we can create it, otherwise we skip it.
				if entry.Mode()&os.ModeSymlink == 0 {
					continue

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Re-run the alloc — this is often a transient race and a fresh chroot build succeeds
  2. Check the wrapped errno: EIO → run filesystem/disk checks (fsck, SMART); ESTALE → remount the network filesystem
  3. Stop processes that mutate chroot source dirs during alloc builds (config management, cron cleanups)
  4. If reproducible on one host, cordon/drain the Nomad client node and investigate host health

Example fix

# before
Couldn't read the file information %!s(*os.fileStat=&{...}): lstat /usr/lib/x.so: no such file or directory
# after
# hold package manager/tmp cleaner during alloc start, then
$ nomad alloc restart <alloc>
Defensive patterns

Strategy: retry

Try / catch

if err := taskDir.Build(fsi, chroot, username); err != nil {
    if strings.Contains(err.Error(), "Couldn't read the file information") {
        // transient race or EIO — backoff and retry the chroot build
        time.Sleep(backoff)
        return retryBuild(taskDir)
    }
    return err
}

Prevention

When it happens

Trigger: fileEntry.Info() returns an error during chroot directory embedding — the file inside the host source directory was deleted concurrently, or the underlying filesystem reported an I/O error / EACCES on the parent dir during lstat.

Common situations: Concurrent modification of host dirs (package upgrade, tmp cleaner racing the alloc build); corrupted or failing disk (EIO) on a chroot source like /usr or /lib; NFS stale-handle errors on network-mounted sources.

Related errors


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