nektos/act · error

Unable to filepath.Walk: %v

Error message

Unable to filepath.Walk: %v

What it means

Thrown by hashFiles() when a file matched by the patterns cannot be opened with os.Open — typically permission denied, the file vanished between walk and open, or it is a special file (socket, device).

Source

Thrown at pkg/exprparser/functions.go:217

		}
	}

	matcher := gitignore.NewMatcher(ps)

	var files []string
	if err := filepath.Walk(impl.config.WorkingDir, func(path string, fi fs.FileInfo, err error) error {
		if err != nil {
			return err
		}
		sansPrefix := strings.TrimPrefix(path, impl.config.WorkingDir+string(filepath.Separator))
		parts := strings.Split(sansPrefix, string(filepath.Separator))
		if fi.IsDir() || !matcher.Match(parts, fi.IsDir()) {
			return nil
		}
		files = append(files, path)
		return nil
	}); err != nil {
		return "", fmt.Errorf("Unable to filepath.Walk: %v", err)
	}

	if len(files) == 0 {
		return "", nil
	}

	hasher := sha256.New()

	for _, file := range files {
		f, err := os.Open(file)
		if err != nil {
			return "", fmt.Errorf("Unable to os.Open: %v", err)
		}

		if _, err := io.Copy(hasher, f); err != nil {
			return "", fmt.Errorf("Unable to io.Copy: %v", err)
		}

View on GitHub (pinned to 4f41128141)

Solutions

  1. Narrow the pattern to the files you actually hash (e.g. 'src/**', '**/go.sum').
  2. Fix read permissions or run act as the file owner.
  3. Exclude problematic directories via more specific patterns.

Example fix

# before
${{ hashFiles('**') }}
# after
${{ hashFiles('**/package-lock.json', 'src/**') }}
Defensive patterns

Strategy: try-catch

Validate before calling

func filesReadable(globs []string) bool {
  for _, g := range globs {
    m, _ := filepath.Glob(g)
    for _, f := range m {
      if fi, err := os.Stat(f); err == nil && fi.Mode().IsRegular() == false { return false }
    }
  }
  return true
}

Try / catch

if _, err := hashFiles(p...); err != nil {
  if strings.Contains(err.Error(), 'os.Open') {
    p = filterToRegularFiles(p) // drop sockets/fifos, retry once
  } else { return err }
}

Prevention

When it happens

Trigger: Broad patterns like '**' matching sockets in .git or runtime dirs; files unreadable by the act process; race with a concurrent build deleting outputs.

Common situations: hashFiles('**') instead of targeted patterns; running act as a different user than the file owner; node_modules or cache dirs with odd permissions.

Related errors


AI-assisted analysis of nektos/act@4f41128141 (2026-08-15). Data as JSON: /api/errors/46ad3d717372ad72. Report an issue: GitHub.