hasura/graphql-engine · error · errors.Error

'%s' is not a directory: %w

Error message

'%s' is not a directory: %w

What it means

The execution path exists and is stat-able, but it is a regular file (or otherwise not a directory). The message formats the base name of the path. Note the wrapped err is stale here — it is nil at this point, so the '%w' verb renders '%!w(<nil>)'.

Source

Thrown at cli/directory.go:55

		if err != nil {
			return errors.E(
				op,
				fmt.Errorf("error finding absolute path for project directory: %w", err),
			)
		}
	}

	ed, err := os.Stat(ec.ExecutionDirectory)
	if err != nil {
		if stderrors.Is(err, fs.ErrNotExist) {
			return errors.E(op, fmt.Errorf("did not find required directory. use 'init'?: %w", err))
		}

		return errors.E(op, fmt.Errorf("error getting directory details: %w", err))
	}

	if !ed.IsDir() {
		return errors.E(op, fmt.Errorf("'%s' is not a directory: %w", ed.Name(), err))
	}
	// config.yaml
	// migrations/
	// (optional) metadata.yaml
	dir, err := recursivelyValidateDirectory(ec.ExecutionDirectory)
	if err != nil {
		return errors.E("validate: %w", err)
	}

	ec.ExecutionDirectory = dir

	return nil
}

// filesRequired are the files that are mandatory to qualify for a project
// directory.
var filesRequired = []string{
	"config.yaml",

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Change the directory argument to the parent folder containing config.yaml, not the file itself
  2. Add a preflight check in scripts: [ -d "$DIR" ] || exit 1
  3. If the wrapped '%!w(<nil>)' output confused you, ignore it — the real issue is the non-directory path

Example fix

# before
mycli --dir ./project/config.yaml run
# after
mycli --dir ./project run
Defensive patterns

Strategy: validation

Validate before calling

info, err := os.Stat(projectDir)
if err != nil {
    log.Fatal(err)
}
if !info.IsDir() {
    log.Fatalf("%s is a file; pass its parent directory instead", projectDir)
}

Type guard

func isDirectory(p string) bool {
    info, err := os.Stat(p)
    return err == nil && info.IsDir()
}

Try / catch

if err := ec.Validate(); err != nil {
    if strings.Contains(err.Error(), "is not a directory") {
        // point --dir at the folder containing config.yaml
    }
}

Prevention

When it happens

Trigger: Passing a path that resolves to a file (e.g. pointing --dir at config.yaml itself or a script) so that ed.IsDir() is false in validateDirectory.

Common situations: Users pointing the directory flag at a file instead of its parent folder; copy-paste of a full file path from docs; glob or variable expansion that yields a file path.

Related errors


AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28). Data as JSON: /api/errors/5bba9f35f57666de. Report an issue: GitHub.