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.
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 errView on GitHub (pinned to a23773e6c3)
Solutions
- Export EDITOR before starting delve: e.g. export EDITOR=vim.
- Set DELVE_EDITOR if you want a delve-specific editor that differs from EDITOR.
- 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
- Export EDITOR in shell rc files (~/.bashrc, ~/.zshrc)
- Set DELVE_EDITOR for a delve-specific editor
- Remember delve does not read VISUAL; mirror it to EDITOR
- In containers/CI, bake EDITOR into the image env
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
- command not available
- unknown config parameter
- not documented
- you must specify a thread
- too many arguments to goroutine
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/3cf73c9dfd599ce3.
Report an issue: GitHub.