hasura/graphql-engine · error

cannot create seeds directory: %w

Error message

cannot create seeds directory: %w

What it means

A metadata value referenced a secret by name via `from_env`/secret interpolation, but no environment variable/secret with that name was found in the resolver's environment. The resolver resolves secret references eagerly and fails when missing.

Source

Thrown at cli/cli.go:758

			"cannot get config information from server, this might be because config API is not enabled: %v",
			err,
		)
	}

	// set name of migration directory
	ec.MigrationDir = filepath.Join(ec.ExecutionDirectory, ec.Config.MigrationsDirectory)
	if _, err := os.Stat(ec.MigrationDir); stderrors.Is(err, fs.ErrNotExist) {
		err = os.MkdirAll(ec.MigrationDir, os.ModePerm)
		if err != nil {
			return errors.E(op, fmt.Errorf("cannot create migrations directory: %w", err))
		}
	}

	ec.SeedsDirectory = filepath.Join(ec.ExecutionDirectory, ec.Config.SeedsDirectory)
	if _, err := os.Stat(ec.SeedsDirectory); stderrors.Is(err, fs.ErrNotExist) {
		err = os.MkdirAll(ec.SeedsDirectory, os.ModePerm)
		if err != nil {
			return errors.E(op, fmt.Errorf("cannot create seeds directory: %w", err))
		}
	}

	if ec.Config.Version >= V2 && ec.Config.MetadataDirectory != "" {
		if len(ec.Config.MetadataFile) > 0 {
			ec.MetadataFile = filepath.Join(ec.ExecutionDirectory, ec.Config.MetadataFile)
			if _, err := os.Stat(ec.MetadataFile); stderrors.Is(err, fs.ErrNotExist) {
				err := os.WriteFile(ec.MetadataFile, []byte(""), os.ModePerm)
				if err != nil {
					return errors.E(op, err)
				}
			}

			switch filepath.Ext(ec.MetadataFile) {
			case ".json":
				ec.MetadataMode = MetadataModeJSON
			case ".yaml":
				ec.MetadataMode = MetadataModeYAML

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Set the missing environment variable/secret named in the error and re-run
  2. Verify the exact name spelling and case in both metadata and environment
  3. For deployments, ensure the secret is injected into the container/process environment

Example fix

# before
from_env: DATABASE_PASSWRD
# after
from_env: DATABASE_PASSWORD
# and: export DATABASE_PASSWORD=...
Defensive patterns

Strategy: validation

Validate before calling

for name in referenced_secrets(&metadata) {
    assert!(std::env::var(&name).is_ok(), "secret {name} missing from environment");
}

Prevention

When it happens

Trigger: Metadata containing something like `{{env.MY_SECRET}}` or `from_env: MY_SECRET` where MY_SECRET is not set in the process environment at resolve time.

Common situations: Deploying without setting required env vars; local runs missing the .env file; renaming env vars in one environment but not the metadata; CI pipelines not injecting secrets.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


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