{"record":{"id":"e47e857cfd201e10","repo":"go-task/task","slug":"task-you-can-t-set-both-download-and-offline","errorCode":null,"errorMessage":"task: You can't set both --download and --offline flags","messagePattern":"task: You can't set both --download and --offline flags","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/flags/flags.go","lineNumber":205,"sourceCode":"\t\t\tColor = true\n\t\t\tcolor.NoColor = false // Force colors even without TTY\n\t\t}\n\t\t// Otherwise, let fatih/color auto-detect TTY\n\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 {","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/go-task/task/blob/385e5ad92af02877b6d7cf9dcc963b5ed916e70a/internal/flags/flags.go#L187-L223","documentation":"Validate() in internal/flags rejects mutually exclusive CLI flags. --download fetches the remote Task binary/instances while --offline forbids network access, so combining them is contradictory. The library throws this plain error early during startup rather than behaving ambiguously.","triggerScenarios":"Running `task --download --offline ...` so that both flags.Download and flags.Offline are true when Validate() is called from run().","commonSituations":"Shell aliases or wrapper scripts that hardcode --offline while the user adds --download; CI scripts appending download flags to a cached offline invocation.","solutions":["Remove either --download or --offline from the command line","Check shell aliases/functions/wrappers for a hardcoded --offline or --download","Split the use cases: run --download once, then run with --offline separately"],"exampleFix":"# before\ntask --download --offline\n\n# after\ntask --download   # or: task --offline","handlingStrategy":"validation","validationCode":"if flags.Download && flags.Offline {\n\treturn errors.New(\"cannot combine --download with --offline\")\n}","typeGuard":null,"tryCatchPattern":"if err := flags.Validate(); err != nil {\n\tif strings.Contains(err.Error(), \"--download and --offline\") {\n\t\tfmt.Fprintln(os.Stderr, \"pick one: --download (needs network) or --offline (no network)\")\n\t\tos.Exit(2)\n\t}\n\treturn err\n}","preventionTips":["Never hardcode --offline in aliases that users may augment with --download","Treat --download as an explicit online-mode request and keep it out of offline scripts","Document mutually exclusive flag pairs in your wrapper scripts"],"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"}