{"record":{"id":"3cf73c9dfd599ce3","repo":"go-delve/delve","slug":"neither-delve-editor-or-editor-is-set","errorCode":null,"errorMessage":"Neither DELVE_EDITOR or EDITOR is set","messagePattern":"Neither DELVE_EDITOR or EDITOR is set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/terminal/command.go","lineNumber":2023,"sourceCode":"}\n\nfunc tracepoint(t *Term, ctx callContext, args string) error {\n\tif ctx.Prefix == onPrefix {\n\t\tif args != \"\" {\n\t\t\treturn errors.New(\"too many arguments to trace\")\n\t\t}\n\t\tctx.Breakpoint.Tracepoint = true\n\t\treturn nil\n\t}\n\t_, err := setBreakpoint(t, ctx, true, args)\n\treturn err\n}\n\nfunc getEditorName() (string, []string, error) {\n\tvar editor string\n\tif editor = os.Getenv(\"DELVE_EDITOR\"); editor == \"\" {\n\t\tif editor = os.Getenv(\"EDITOR\"); editor == \"\" {\n\t\t\treturn \"\", nil, errors.New(\"Neither DELVE_EDITOR or EDITOR is set\")\n\t\t}\n\t}\n\n\teditorParts := strings.Fields(editor)\n\teditor = editorParts[0]\n\n\tvar userArgs []string\n\tif len(editorParts) > 1 {\n\t\tuserArgs = editorParts[1:]\n\t}\n\n\treturn editor, userArgs, nil\n}\n\nfunc runEditor(args ...string) error {\n\teditor, userArgs, err := getEditorName()\n\tif err != nil {\n\t\treturn err","sourceCodeStart":2005,"sourceCodeEnd":2041,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/terminal/command.go#L2005-L2041","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (shell)\ndlv debug\n(dlv) edit\n// error: Neither DELVE_EDITOR or EDITOR is set\n// after\nexport EDITOR=vim\ndlv debug\n(dlv) edit","handlingStrategy":"fallback","validationCode":"editor := os.Getenv(\"DELVE_EDITOR\")\nif editor == \"\" {\n    editor = os.Getenv(\"EDITOR\")\n}\nif editor == \"\" {\n    return errors.New(\"set EDITOR before running dlv edit\")\n}","typeGuard":null,"tryCatchPattern":"if _, _, err := getEditorName(); err != nil {\n    if strings.Contains(err.Error(), \"DELVE_EDITOR or EDITOR\") {\n        os.Setenv(\"EDITOR\", \"vi\") // fallback editor\n    }\n    return err\n}","preventionTips":["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"],"tags":["terminal","environment","editor"],"backgroundTag":"missing-env-var","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}