go-delve/delve · error

Neither DELVE_EDITOR or EDITOR is set

Error message

Neither DELVE_EDITOR or EDITOR is set

What it means

Delve's 'edit' command launches an external editor, which it locates via the DELVE_EDITOR environment variable, falling back to EDITOR. If both are empty there is no program to spawn, so getEditorName returns this error before attempting any execution.

Solutions

  1. Export EDITOR before starting delve: e.g. export EDITOR=vim.
  2. Set DELVE_EDITOR if you want a delve-specific editor that differs from EDITOR.
  3. If you set VISUAL, also mirror it to EDITOR since Delve does not read VISUAL.

Example fix

// before (shell)
dlv debug
(dlv) edit
// error: Neither DELVE_EDITOR or EDITOR is set
// after
export EDITOR=vim
dlv debug
(dlv) edit
Defensive patterns

Strategy: fallback

Validate before calling

editor := os.Getenv("DELVE_EDITOR")
if editor == "" {
    editor = os.Getenv("EDITOR")
}
if editor == "" {
    return errors.New("set EDITOR before running dlv edit")
}

Try / catch

if _, _, err := getEditorName(); err != nil {
    if strings.Contains(err.Error(), "DELVE_EDITOR or EDITOR") {
        os.Setenv("EDITOR", "vi") // fallback editor
    }
    return err
}

Prevention

When it happens

Trigger: Running the 'edit' command in the Delve terminal on a machine where neither DELVE_EDITOR nor EDITOR is exported in the shell environment that launched dlv.

Common situations: CI containers, minimal Docker images, fresh servers, or systemd-launched shells where EDITOR is never set; also users who set VISUAL only, which Delve does not consult.

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 go-delve/delve@a23773e6c3 (2026-08-31). Data as JSON: /api/errors/3cf73c9dfd599ce3. Report an issue: GitHub.

Appendix: source

Thrown at pkg/terminal/command.go:2023

}

func tracepoint(t *Term, ctx callContext, args string) error {
	if ctx.Prefix == onPrefix {
		if args != "" {
			return errors.New("too many arguments to trace")
		}
		ctx.Breakpoint.Tracepoint = true
		return nil
	}
	_, err := setBreakpoint(t, ctx, true, args)
	return err
}

func getEditorName() (string, []string, error) {
	var editor string
	if editor = os.Getenv("DELVE_EDITOR"); editor == "" {
		if editor = os.Getenv("EDITOR"); editor == "" {
			return "", nil, errors.New("Neither DELVE_EDITOR or EDITOR is set")
		}
	}

	editorParts := strings.Fields(editor)
	editor = editorParts[0]

	var userArgs []string
	if len(editorParts) > 1 {
		userArgs = editorParts[1:]
	}

	return editor, userArgs, nil
}

func runEditor(args ...string) error {
	editor, userArgs, err := getEditorName()
	if err != nil {
		return err

View on GitHub (pinned to a23773e6c3)