go-task/task · error

task: You can't set both --download and --offline flags

Error message

task: You can't set both --download and --offline flags

What it means

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.

Source

Thrown at internal/flags/flags.go:205

			Color = true
			color.NoColor = false // Force colors even without TTY
		}
		// Otherwise, let fatih/color auto-detect TTY
	} 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 {

View on GitHub (pinned to 385e5ad92a)

Solutions

  1. Remove either --download or --offline from the command line
  2. Check shell aliases/functions/wrappers for a hardcoded --offline or --download
  3. Split the use cases: run --download once, then run with --offline separately

Example fix

# before
task --download --offline

# after
task --download   # or: task --offline
Defensive patterns

Strategy: validation

Validate before calling

if flags.Download && flags.Offline {
	return errors.New("cannot combine --download with --offline")
}

Try / catch

if err := flags.Validate(); err != nil {
	if strings.Contains(err.Error(), "--download and --offline") {
		fmt.Fprintln(os.Stderr, "pick one: --download (needs network) or --offline (no network)")
		os.Exit(2)
	}
	return err
}

Prevention

When it happens

Trigger: Running `task --download --offline ...` so that both flags.Download and flags.Offline are true when Validate() is called from run().

Common situations: Shell aliases or wrapper scripts that hardcode --offline while the user adds --download; CI scripts appending download flags to a cached offline invocation.

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


AI-assisted analysis of go-task/task@385e5ad92a (2026-09-05). Data as JSON: /api/errors/e47e857cfd201e10. Report an issue: GitHub.