{"record":{"id":"5bb0764e2de5d7eb","repo":"Jguer/yay","slug":"editor-did-not-exit-successfully-aborting-s","errorCode":null,"errorMessage":"editor did not exit successfully, aborting: %s","messagePattern":"editor did not exit successfully, aborting: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/menus/edit_menu.go","lineNumber":110,"sourceCode":"\t\tpkgbuilds = append(pkgbuilds, filepath.Join(dir, \"PKGBUILD\"))\n\n\t\tif srcinfos != nil {\n\t\t\tfor _, splitPkg := range srcinfos[pkg].SplitPackages() {\n\t\t\t\tif splitPkg.Install != \"\" {\n\t\t\t\t\tpkgbuilds = append(pkgbuilds, filepath.Join(dir, splitPkg.Install))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(pkgbuilds) > 0 {\n\t\teditor, editorArgs := editor(log, editorConfig, editorFlags, noConfirm)\n\t\teditorArgs = append(editorArgs, pkgbuilds...)\n\t\teditcmd := exec.CommandContext(context.Background(), editor, editorArgs...)\n\t\teditcmd.Stdin, editcmd.Stdout, editcmd.Stderr = os.Stdin, os.Stdout, os.Stderr\n\n\t\tif err := editcmd.Run(); err != nil {\n\t\t\treturn errors.New(gotext.Get(\"editor did not exit successfully, aborting: %s\", err))\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc EditFn(ctx context.Context, run *runtime.Runtime, w io.Writer,\n\tpkgbuildDirsByBase map[string]string, installed mapset.Set[string],\n) error {\n\tif len(pkgbuildDirsByBase) == 0 {\n\t\treturn nil // no work to do\n\t}\n\n\tbases := make([]string, 0, len(pkgbuildDirsByBase))\n\tfor pkg := range pkgbuildDirsByBase {\n\t\tbases = append(bases, pkg)\n\t}\n","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/menus/edit_menu.go#L92-L128","documentation":"This error is created in editPkgbuilds (pkg/menus/edit_menu.go:110) when the spawned external editor process (exec.CommandContext(...).Run()) exits with a non-zero status or fails to start. It wraps the underlying exec error into a user-facing message 'editor did not exit successfully, aborting: %s' so the caller aborts PKGBUILD editing instead of continuing with possibly unmodified files.","triggerScenarios":"The configured editor exits non-zero while editing PKGBUILDs; the EDITOR/VISUAL value points to a binary that cannot be executed (exec.ExitError or exec.Error from editcmd.Run()).","commonSituations":"EDITOR set to a nonexistent binary or a path with spaces unquoted; user quits vim/nano with a non-zero exit (:cq in vim); editor is a GUI app failing in a headless environment; EDITOR includes CLI flags the parser mishandles.","solutions":["Fix or set the EDITOR/VISUAL environment variable to a valid, executable editor (e.g. export EDITOR=vim).","If vim exited via :cq, reopen and exit normally (save with :wq or quit with :q) — non-zero exit intentionally aborts.","Ensure the editor binary is installed and on PATH; check the wrapped error text for 'executable file not found'.","Set yay/yazi-style config editor correctly (e.g. aurman/pikaur config editor option) if a project-specific editor setting overrides EDITOR."],"exampleFix":"// before\nEDITOR=/usr/bin/my gui-editor yay -S foo   # fails headless\n// after\nexport EDITOR=/usr/bin/vim\nyay -S foo","handlingStrategy":"try-catch","validationCode":"editor := os.Getenv(\"EDITOR\")\nif editor == \"\" {\n    editor = os.Getenv(\"VISUAL\")\n}\nif editor == \"\" || exec.Command(\"sh\", \"-c\", \"command -v \"+editor).Run() != nil {\n    return errors.New(\"no usable $EDITOR found\")\n}","typeGuard":"var exitErr *exec.ExitError\nif errors.As(err, &exitErr) {\n    // editor ran but exited non-zero (e.g. vim :cq)\n}","tryCatchPattern":"if err := editPkgbuilds(...); err != nil {\n    if strings.Contains(err.Error(), \"editor did not exit successfully\") {\n        // surface wrapped cause to user; do not proceed with build\n        return fmt.Errorf(\"aborted: %w\", err)\n    }\n    return err\n}","preventionTips":["Set EDITOR to a known-good terminal editor available on PATH","Avoid exiting vim/nano with non-zero status (:cq) when you want edits kept","In headless/CI environments configure a non-interactive editor or skip editing","Quote editor paths with spaces correctly in EDITOR"],"tags":["editor","exec","process","user-input"],"backgroundTag":"git-command-failed","analyzedSha":"328f4b4939fb35f38c2f7c7ce3b8638a839bafa5","analyzedAt":"2026-09-07T16:45:12.608Z","contentChangedAt":"2026-09-07T16:45:12.608Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}