hasura/graphql-engine · error
error walking the directory path: %w
Error message
error walking the directory path: %w
What it means
When no explicit seed files are given, ApplySeedsToDatabase walks the entire seeds directory with afero.Walk; this error wraps any failure of that walk itself (not per-file read errors, which are reported separately). Typical causes are the seeds directory not existing or being unreadable.
Source
Thrown at cli/seed/apply.go:93
} else {
err := afero.Walk(fs, seedsDirectory, func(path string, file os.FileInfo, err error) error {
if file == nil || err != nil {
return errors.E(op, err)
}
if err := hasAllowedSeedFileExtensions(file.Name()); err == nil && !file.IsDir() {
b, err := afero.ReadFile(fs, path)
if err != nil {
return errors.E(op, fmt.Errorf("error opening file: %w", err))
}
sqlAsBytes = append(sqlAsBytes, b)
}
return nil
})
if err != nil {
return errors.E(op, fmt.Errorf("error walking the directory path: %w", err))
}
}
var args []hasura.RequestBody
sourceKind := getSourceKind(source)
switch sourceKind {
case hasura.SourceKindPG:
for _, sql := range sqlAsBytes {
request := hasura.RequestBody{
Type: "run_sql",
Args: hasura.PGRunSQLInput{
SQL: string(sql),
Source: source.Name,
},
}
args = append(args, request)
}View on GitHub (pinned to 724551b9ae)
Solutions
- Confirm the seeds directory exists and is a directory: ls -ld <project>/seeds; create it with mkdir seeds if missing.
- Fix directory permissions: chmod +rx on seeds/ and all subdirectories (find seeds -type d -exec chmod +rx {} +).
- Check the config for a custom seeds_directory setting pointing at the wrong path.
- Remove non-directory entries named 'seeds' and recreate the folder.
Example fix
# before $ hasura seed apply error walking the directory path: open ./seeds: no such file or directory # after $ mkdir -p seeds && echo 'CREATE TABLE t(id int);' > seeds/0-init.sql $ hasura seed apply
Defensive patterns
Strategy: validation
Validate before calling
fi, err := os.Stat(seedsDirectory)
if err != nil { /* create it or fix config */ }
if !fi.IsDir() { return fmt.Errorf("%s is not a directory", seedsDirectory) }
// ensure subdirs are listable
filepath.WalkDir(seedsDirectory, func(p string, d fs.DirEntry, err error) error {
if err != nil { return err }
return nil
}) Type guard
func isReadableDir(path string) bool {
fi, err := os.Stat(path)
return err == nil && fi.IsDir() && fi.Mode().Perm()&0o500 == 0o500
} Try / catch
if err := ApplySeedsToDatabase(...); err != nil && strings.Contains(err.Error(), "error walking the directory path") {
if errors.Is(err, fs.ErrNotExist) { os.MkdirAll(seedsDir, 0o755) /* retry */ }
} Prevention
- Commit an empty seeds/ directory (with a .gitkeep) so clones always have it.
- Double-check custom seeds_directory values in config.yaml.
- Run find seeds -type d -exec chmod +rx {} + after permission changes.
When it happens
Trigger: Running `hasura seed apply` (directory mode) when seedsDirectory does not exist, is a regular file instead of a directory, or a subdirectory inside it cannot be listed due to missing execute/read permission.
Common situations: The seeds/ folder was never created or was renamed (e.g. to database/seed/); directory permissions were tightened after copying the project; or a nested directory in seeds/ is owned by root from a Docker run.
Related errors
- getting list of seed files to move: %w
- error opening file: %w
- creating metadata file %s failed: %w
- getting list of migrations to move: %w
- creating target seeds directory: %w
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/05ea4f954e1317bf.
Report an issue: GitHub.