Jguer/yay · error

%s %s: %w

Error message

%s %s: %w

What it means

runAUREvent invokes each registered Lua autocmd callback for an event via gopher-lua's protected call; if the Lua function errors or panics inside Lua, the failure is wrapped as '<eventName> <pkgBase>: <lua error>'. The Go side cannot proceed with the event handling because a user script failed. wrapLuaErr strips the gopher-lua wrapper so the underlying script message is surfaced.

Solutions

  1. Read the wrapped Lua error message to find the failing line in your autocmd callback
  2. Fix the nil reference/typo in the Lua callback
  3. Update the script if event table fields changed after an upgrade
  4. Temporarily remove the autocmd registration to confirm the script is the cause
  5. Use abort() intentionally if you want to halt the operation cleanly

Example fix

-- before
autocmd('PreInstall', function(e) install_extra(e.base) end)
-- after
autocmd('PreInstall', function(e)
  if type(e.base) ~= 'string' then abort('missing base') end
  install_extra(e.base)
end)
Defensive patterns

Strategy: try-catch

Validate before calling

-- in your Lua config, sanity-check the callback before registering
local ok, err = pcall(function() assert(type(myHook) == 'function') end)
if not ok then error('bad autocmd callback: ' .. tostring(err)) end

Try / catch

if err := engine.RunAURHook(eventName, event); err != nil {
	log.Warnf("autocmd failed, continuing without it: %v", err)
}

Prevention

When it happens

Trigger: An autocmd registered for an AUR event (e.g. via createAutocmd) whose callback raises a Lua runtime error (calling nil, bad index, abort()) while processing an event for package event.Base.

Common situations: User Lua config script has a typo or references an undefined helper; the callback expects a different event table shape after a yay version change; abort() used deliberately in the script to stop operations.

Related errors


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

Appendix: source

Thrown at pkg/settings/lua/autocmd.go:203

	return e.runAUREvent(EventAURPreInstall, event)
}

func (e *Engine) RunAURPostDownload(event *AURPreInstallEvent) error {
	return e.runAUREvent(EventAURPostDownload, event)
}

func (e *Engine) runAUREvent(eventName string, event *AURPreInstallEvent) error {
	if !e.HasAutocmd(eventName) {
		return nil
	}

	for _, autocmd := range e.autocmds[eventName] {
		if err := e.L.CallByParam(glua.P{
			Fn:      autocmd.callback,
			NRet:    0,
			Protect: true,
		}, e.aurEventTable(eventName, event)); err != nil {
			return fmt.Errorf("%s %s: %w", eventName, event.Base, wrapLuaErr(err))
		}
	}

	return nil
}

func (e *Engine) RunUpgradeSelect(event *UpgradeSelectEvent) (UpgradeSelectResult, error) {
	var result UpgradeSelectResult
	if !e.HasAutocmd(EventUpgradeSelect) {
		return result, nil
	}

	validExcludes := mapset.NewThreadUnsafeSetWithSize[string](len(event.Upgrades))
	for i := range event.Upgrades {
		validExcludes.Add(event.Upgrades[i].Name)
	}

	seenExcludes := mapset.NewThreadUnsafeSet[string]()

View on GitHub (pinned to 328f4b4939)