{"record":{"id":"bacc007e886fce59","repo":"go-task/task","slug":"task-you-can-t-set-both-download-and-clear-ca","errorCode":null,"errorMessage":"task: You can't set both --download and --clear-cache flags","messagePattern":"task: You can't set both --download and --clear-cache flags","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/flags/flags.go","lineNumber":209,"sourceCode":"\t} else {\n\t\t// Explicit config: sync with fatih/color\n\t\tcolor.NoColor = !Color\n\t}\n}\n\n// isCI returns true if running in a CI environment\nfunc isCI() bool {\n\tci, _ := strconv.ParseBool(os.Getenv(\"CI\"))\n\treturn ci\n}\n\nfunc Validate() error {\n\tif Download && Offline {\n\t\treturn errors.New(\"task: You can't set both --download and --offline flags\")\n\t}\n\n\tif Download && ClearCache {\n\t\treturn errors.New(\"task: You can't set both --download and --clear-cache flags\")\n\t}\n\n\tif Global && Dir != \"\" {\n\t\treturn errors.New(\"task: You can't set both --global and --dir\")\n\t}\n\n\tif Output.Name != \"group\" {\n\t\tif Output.Group.Begin != \"\" {\n\t\t\treturn errors.New(\"task: You can't set --output-group-begin without --output=group\")\n\t\t}\n\t\tif Output.Group.End != \"\" {\n\t\t\treturn errors.New(\"task: You can't set --output-group-end without --output=group\")\n\t\t}\n\t\tif Output.Group.ErrorOnly {\n\t\t\treturn errors.New(\"task: You can't set --output-group-error-only without --output=group\")\n\t\t}\n\t}\n","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/go-task/task/blob/385e5ad92af02877b6d7cf9dcc963b5ed916e70a/internal/flags/flags.go#L191-L227","documentation":"Validate() rejects using --download together with --clear-cache. --clear-cache removes the downloaded Task cache while --download populates it, so running both in one invocation is contradictory. The error is returned before any task runs.","triggerScenarios":"Running `task --download --clear-cache ...` so both boolean flags are true when Validate() executes.","commonSituations":"Chained commands like `task --clear-cache && task --download` accidentally merged into one invocation; scripts that always pass --clear-cache for freshness.","solutions":["Remove one of the two flags from the invocation","If you want a fresh binary: run --clear-cache first, then --download in a separate command","Inspect wrapper scripts/aliases that inject --clear-cache"],"exampleFix":"# before\ntask --download --clear-cache\n\n# after\ntask --clear-cache && task --download","handlingStrategy":"validation","validationCode":"if flags.Download && flags.ClearCache {\n\treturn errors.New(\"cannot combine --download with --clear-cache\")\n}","typeGuard":null,"tryCatchPattern":"if err := flags.Validate(); err != nil {\n\tif strings.Contains(err.Error(), \"--download and --clear-cache\") {\n\t\tfmt.Fprintln(os.Stderr, \"run --clear-cache and --download as separate invocations\")\n\t\tos.Exit(2)\n\t}\n\treturn err\n}","preventionTips":["Sequence cache reset and re-download as two separate commands","Avoid baking --clear-cache into every invocation 'for freshness'","Check chained shell commands for merged flags"],"tags":["cli","flags","go-task"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"385e5ad92af02877b6d7cf9dcc963b5ed916e70a","analyzedAt":"2026-09-05T09:01:05.226Z","contentChangedAt":"2026-09-05T09:01:05.226Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}