go-task/task · error
task: You can't set both --download and --clear-cache flags
Error message
task: You can't set both --download and --clear-cache flags
What it means
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.
Source
Thrown at internal/flags/flags.go:209
} else {
// Explicit config: sync with fatih/color
color.NoColor = !Color
}
}
// isCI returns true if running in a CI environment
func isCI() bool {
ci, _ := strconv.ParseBool(os.Getenv("CI"))
return ci
}
func Validate() error {
if Download && Offline {
return errors.New("task: You can't set both --download and --offline flags")
}
if Download && ClearCache {
return errors.New("task: You can't set both --download and --clear-cache flags")
}
if Global && Dir != "" {
return errors.New("task: You can't set both --global and --dir")
}
if Output.Name != "group" {
if Output.Group.Begin != "" {
return errors.New("task: You can't set --output-group-begin without --output=group")
}
if Output.Group.End != "" {
return errors.New("task: You can't set --output-group-end without --output=group")
}
if Output.Group.ErrorOnly {
return errors.New("task: You can't set --output-group-error-only without --output=group")
}
}
View on GitHub (pinned to 385e5ad92a)
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
Example fix
# before task --download --clear-cache # after task --clear-cache && task --download
Defensive patterns
Strategy: validation
Validate before calling
if flags.Download && flags.ClearCache {
return errors.New("cannot combine --download with --clear-cache")
} Try / catch
if err := flags.Validate(); err != nil {
if strings.Contains(err.Error(), "--download and --clear-cache") {
fmt.Fprintln(os.Stderr, "run --clear-cache and --download as separate invocations")
os.Exit(2)
}
return err
} Prevention
- 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
When it happens
Trigger: Running `task --download --clear-cache ...` so both boolean flags are true when Validate() executes.
Common situations: Chained commands like `task --clear-cache && task --download` accidentally merged into one invocation; scripts that always pass --clear-cache for freshness.
Understand the failure class
Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.
Related errors
- task: You can't set both --download and --offline flags
- task: You can't set both --global and --dir
- task: You can't set --output-group-begin without --output=gr
- task: You can't set --output-group-end without --output=grou
- task: You can't set --output-group-error-only without --outp
AI-assisted analysis of go-task/task@385e5ad92a (2026-09-05).
Data as JSON: /api/errors/bacc007e886fce59.
Report an issue: GitHub.