Jguer/yay · error
init.lua
Error message
init.lua: %w
What it means
Load runs the bundled init.lua and collects every error found while executing it and applying its yay.opt table, wrapping each one with an 'init.lua: ' prefix and joining them with errors.Join. It exists so a user with a broken Lua settings file sees ALL problems at once, not just the first. If any errors were collected, the engine is closed and the joined error is returned, so Load never partially succeeds.
Solutions
- Read each 'init.lua: '-prefixed line in the returned (joined) error; each line is one independent problem
- Fix every unknown yay.opt key listed — remove it or rename it to a key the current version supports
- Fix the underlying Lua error(s) reported after the prefix (syntax/runtime error, type mismatch)
- Re-run Load until it returns no error; the multi-error report updates with remaining issues
Example fix
// before (init.lua) yay.opt.daemon_interval = 10 -- unknown/renamed key // after yay.opt.devel_interval = 10
Defensive patterns
Strategy: validation
Validate before calling
// Pre-validate init.lua with a dry engine before committing settings
engine, err := lua.Load(dir)
if err != nil {
for _, line := range strings.Split(err.Error(), "\n") {
log.Printf("init.lua problem: %s", line)
}
return err
} Try / catch
if err := runLoad(); err != nil {
var joined interface{ Unwrap() []error }
if errors.As(err, &joined) { for _, e := range joined.Unwrap() { handle(e) } }
} Prevention
- Run Load in CI against the real init.lua so bad keys fail the build
- Keep a test that Applies a canary init.lua listing every supported yay.opt key
- After upgrading yay, grep init.lua for renamed keys and diff against the current schema
When it happens
Trigger: Calling Load on a directory whose init.lua either fails to execute (syntax error, runtime error in Lua) or contains one or more unknown yay.opt keys or values that fail type validation in Apply.
Common situations: See trigger scenarios.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
AI-assisted analysis of Jguer/yay@328f4b4939 (2026-09-07).
Data as JSON: /api/errors/f0254ba34f6f8292.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/settings/lua/load.go:39
if err := engine.L.DoFile(path); err != nil {
engine.Close()
return nil, err
}
unknown, errs := engine.Apply(cfg)
if len(unknown) == 0 && len(errs) == 0 {
return engine, nil
}
var joinErrs []error
for _, key := range unknown {
joinErrs = append(joinErrs, fmt.Errorf("init.lua: unknown yay.opt key: %s", key))
}
for _, err := range errs {
joinErrs = append(joinErrs, fmt.Errorf("init.lua: %w", err))
}
if err := errors.Join(joinErrs...); err != nil {
engine.Close()
return nil, err
}
return engine, nil
}
// LoadInto applies the yay.opt values from path onto cfg.
func LoadInto(logger *text.Logger, path string, cfg any) error {
engine, err := Load(logger, path, cfg)
if engine != nil {
defer engine.Close()
}
return errView on GitHub (pinned to 328f4b4939)