hasura/graphql-engine · error

cannot find default editor from env: %w

Error message

cannot find default editor from env: %w

What it means

Raised when the CLI cannot capture input from the user's editor while running `hasura seed create` without --from-table. It wraps failures from editor.GetPreferredEditorFromEnvironment (finding $EDITOR/$VISUAL) and from launching/capturing the editor session.

Source

Thrown at cli/commands/seed_create.go:158

				return errors.E(op, fmt.Errorf("exporting seed data: %w", err))
			}

			body, err = io.ReadAll(bodyReader)
			if err != nil {
				return errors.E(op, err)
			}
		} else {
			const defaultText = ""

			var err error

			body, err = editor.CaptureInputFromEditor(
				editor.GetPreferredEditorFromEnvironment,
				defaultText,
				"sql",
			)
			if err != nil {
				return errors.E(op, fmt.Errorf("cannot find default editor from env: %w", err))
			}
		}

		createSeedOpts.Data = bytes.NewReader(body)
	}

	fs := afero.NewOsFs()

	filepath, err := seed.CreateSeedFile(fs, createSeedOpts)
	if err != nil || filepath == nil {
		return errors.E(op, fmt.Errorf("failed to create seed file: %w", err))
	}

	o.FilePath = *filepath

	return nil
}

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Set EDITOR (or VISUAL) to an installed editor: `export EDITOR=vim`
  2. Verify the editor binary exists on PATH (`which $EDITOR`)
  3. In non-interactive contexts, skip the editor by using `--from-table` or pre-create the seed file manually under seeds/

Example fix

# before
docker run hasura/cli seed create s1  # no EDITOR
# after
docker run -e EDITOR=vi hasura/cli seed create s1
Defensive patterns

Strategy: validation

Validate before calling

// ensure an editor is configured before launching an interactive seed create
if os.Getenv("EDITOR") == "" && os.Getenv("VISUAL") == "" {
    return errors.New("set $EDITOR (e.g. export EDITOR=vim) or use --from-table")
}

Prevention

When it happens

Trigger: EDITOR and VISUAL environment variables are unset and no default editor can be found, or the resolved editor binary cannot be spawned/exited non-zero during CaptureInputFromEditor.

Common situations: CI/cron or container environments with no EDITOR set, ssh sessions without env, a misconfigured EDITOR pointing to a missing binary.

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/799d476d4844777f. Report an issue: GitHub.