Jguer/yay · error
invalid option
Error message
invalid option
What it means
Parse rejects argument combinations incompatible with the requested operation. When no operation-compatible path is taken and the -c/--clean flag is present, yay cannot disambiguate it, so it prints guidance (the clean command requires an operation; did you mean -Scc or -Ycc) and returns this error. It exists because bare 'yay -c' is ambiguous in the yay CLI.
Solutions
- Replace bare -c with an explicit operation: 'yay -Scc' to clean the package cache or 'yay -Ycc' to clean unneeded orphan packages.
- If you want a combined upgrade-and-clean, use 'yay -Syu' followed by 'yay -Scc' as separate commands.
- Update scripts/docs that reference 'yay -c' to the current yay syntax.
Example fix
// before $ yay -c invalid option // after $ yay -Scc # clean package cache $ yay -Ycc # clean unneeded orphans
Defensive patterns
Strategy: validation
Validate before calling
// before invoking the parser, reject a bare clean flag
for _, arg := range args {
if arg == "-c" || arg == "--clean" {
hasClean = true
}
}
if hasClean && !hasOperation(args) {
return fmt.Errorf("use -Scc or -Ycc instead of bare -c")
} Try / catch
if err := settings.Parse(cfg, args); err != nil {
if strings.Contains(err.Error(), "invalid option") {
// print hint: -Scc / -Ycc
return nil
}
return err
} Prevention
- Never pass -c/--clean without an operation (-Scc, -Ycc).
- Update wrapper scripts after yay CLI changes.
- Wrap parse errors with the command line for easier diagnosis.
When it happens
Trigger: Running yay with -c or --clean without an accompanying operation (e.g. 'yay -c'), which hits the ExistsArg("c", "clean") branch in the else-clause of Parse's top-level argument handling.
Common situations: Users upgrading from pacman habits ('pacman -Sc') trying 'yay -c'; scripts written for older yay versions where -c cleaned caches; typos like 'yay -cs' instead of 'yay -Scc'.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- failed to parse
- package not found in repos
- only one operation may be used at a time
- invalid option
- argument '-' specified without input on stdin
AI-assisted analysis of Jguer/yay@328f4b4939 (2026-09-07).
Data as JSON: /api/errors/a05cad77f2f74189.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/settings/parser/parser.go:669
if err != nil {
return err
}
}
if a.Op == "" {
if a.ExistsArg("h", "help") {
return nil
}
if len(a.Targets) > 0 {
a.Op = "Y"
} else {
// Handle args incompatible with -Syu
if a.ExistsArg("c", "clean") {
fmt.Println(gotext.Get("the clean command requires an operation to be specified"))
fmt.Println(gotext.Get("did you mean yay -Scc (clean caches) or yay -Ycc (clean orphaned packages)?"))
return errors.New(gotext.Get("invalid option"))
}
if _, err := a.parseShortOption("-Syu", ""); err != nil {
return err
}
}
}
if a.ExistsArg("-") {
if err := a.parseStdin(); err != nil {
return err
}
a.DelArg("-")
file, err := os.Open("/dev/tty")
if err != nil {
return errView on GitHub (pinned to 328f4b4939)