Jguer/yay · error

editor did not exit successfully, aborting

Error message

editor did not exit successfully, aborting: %s

What it means

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.

Solutions

  1. Fix or set the EDITOR/VISUAL environment variable to a valid, executable editor (e.g. export EDITOR=vim).
  2. If vim exited via :cq, reopen and exit normally (save with :wq or quit with :q) — non-zero exit intentionally aborts.
  3. Ensure the editor binary is installed and on PATH; check the wrapped error text for 'executable file not found'.
  4. Set yay/yazi-style config editor correctly (e.g. aurman/pikaur config editor option) if a project-specific editor setting overrides EDITOR.

Example fix

// before
EDITOR=/usr/bin/my gui-editor yay -S foo   # fails headless
// after
export EDITOR=/usr/bin/vim
yay -S foo
Defensive patterns

Strategy: try-catch

Validate before calling

editor := os.Getenv("EDITOR")
if editor == "" {
    editor = os.Getenv("VISUAL")
}
if editor == "" || exec.Command("sh", "-c", "command -v "+editor).Run() != nil {
    return errors.New("no usable $EDITOR found")
}

Type guard

var exitErr *exec.ExitError
if errors.As(err, &exitErr) {
    // editor ran but exited non-zero (e.g. vim :cq)
}

Try / catch

if err := editPkgbuilds(...); err != nil {
    if strings.Contains(err.Error(), "editor did not exit successfully") {
        // surface wrapped cause to user; do not proceed with build
        return fmt.Errorf("aborted: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: 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()).

Common situations: 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.

Understand the failure class

Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.


AI-assisted analysis of Jguer/yay@328f4b4939 (2026-09-07). Data as JSON: /api/errors/5bb0764e2de5d7eb. Report an issue: GitHub.

Appendix: source

Thrown at pkg/menus/edit_menu.go:110

		pkgbuilds = append(pkgbuilds, filepath.Join(dir, "PKGBUILD"))

		if srcinfos != nil {
			for _, splitPkg := range srcinfos[pkg].SplitPackages() {
				if splitPkg.Install != "" {
					pkgbuilds = append(pkgbuilds, filepath.Join(dir, splitPkg.Install))
				}
			}
		}
	}

	if len(pkgbuilds) > 0 {
		editor, editorArgs := editor(log, editorConfig, editorFlags, noConfirm)
		editorArgs = append(editorArgs, pkgbuilds...)
		editcmd := exec.CommandContext(context.Background(), editor, editorArgs...)
		editcmd.Stdin, editcmd.Stdout, editcmd.Stderr = os.Stdin, os.Stdout, os.Stderr

		if err := editcmd.Run(); err != nil {
			return errors.New(gotext.Get("editor did not exit successfully, aborting: %s", err))
		}
	}

	return nil
}

func EditFn(ctx context.Context, run *runtime.Runtime, w io.Writer,
	pkgbuildDirsByBase map[string]string, installed mapset.Set[string],
) error {
	if len(pkgbuildDirsByBase) == 0 {
		return nil // no work to do
	}

	bases := make([]string, 0, len(pkgbuildDirsByBase))
	for pkg := range pkgbuildDirsByBase {
		bases = append(bases, pkg)
	}

View on GitHub (pinned to 328f4b4939)