{"record":{"id":"a05cad77f2f74189","repo":"Jguer/yay","slug":"invalid-option","errorCode":null,"errorMessage":"invalid option","messagePattern":"invalid option","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/settings/parser/parser.go","lineNumber":669,"sourceCode":"\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif a.Op == \"\" {\n\t\tif a.ExistsArg(\"h\", \"help\") {\n\t\t\treturn nil\n\t\t}\n\n\t\tif len(a.Targets) > 0 {\n\t\t\ta.Op = \"Y\"\n\t\t} else {\n\t\t\t// Handle args incompatible with -Syu\n\t\t\tif a.ExistsArg(\"c\", \"clean\") {\n\t\t\t\tfmt.Println(gotext.Get(\"the clean command requires an operation to be specified\"))\n\t\t\t\tfmt.Println(gotext.Get(\"did you mean yay -Scc (clean caches) or yay -Ycc (clean orphaned packages)?\"))\n\n\t\t\t\treturn errors.New(gotext.Get(\"invalid option\"))\n\t\t\t}\n\n\t\t\tif _, err := a.parseShortOption(\"-Syu\", \"\"); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif a.ExistsArg(\"-\") {\n\t\tif err := a.parseStdin(); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\ta.DelArg(\"-\")\n\n\t\tfile, err := os.Open(\"/dev/tty\")\n\t\tif err != nil {\n\t\t\treturn err","sourceCodeStart":651,"sourceCodeEnd":687,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/settings/parser/parser.go#L651-L687","documentation":"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.","triggerScenarios":"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.","commonSituations":"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'.","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."],"exampleFix":"// before\n$ yay -c\ninvalid option\n// after\n$ yay -Scc   # clean package cache\n$ yay -Ycc   # clean unneeded orphans","handlingStrategy":"validation","validationCode":"// before invoking the parser, reject a bare clean flag\nfor _, arg := range args {\n    if arg == \"-c\" || arg == \"--clean\" {\n        hasClean = true\n    }\n}\nif hasClean && !hasOperation(args) {\n    return fmt.Errorf(\"use -Scc or -Ycc instead of bare -c\")\n}","typeGuard":null,"tryCatchPattern":"if err := settings.Parse(cfg, args); err != nil {\n    if strings.Contains(err.Error(), \"invalid option\") {\n        // print hint: -Scc / -Ycc\n        return nil\n    }\n    return err\n}","preventionTips":["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."],"tags":["cli","parsing","arch-linux","yay"],"backgroundTag":"invalid-cli-argument","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"}