go-task/task · error

task: You can't set --output-group-begin without --output=gr

Error message

task: You can't set --output-group-begin without --output=group

What it means

Flag validation error raised by the Validate function that runs after CLI parsing before any task executes. It fires when the user passes --output-group-begin (start marker for grouped output) but the output mode itself is not 'group', so the marker would be silently ignored. Fix by adding --output=group or removing --output-group-begin.

Source

Thrown at internal/flags/flags.go:218

	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")
		}
	}

	if List && ListAll {
		return errors.New("task: cannot use --list and --list-all at the same time")
	}

	if ListJson && !List && !ListAll {
		return errors.New("task: --json only applies to --list or --list-all")
	}

	if NoStatus && !ListJson {

View on GitHub (pinned to 385e5ad92a)

Solutions

  1. Add `--output=group` to the same invocation
  2. Remove --output-group-begin if you don't want group output
  3. Check env/config files that may set the group-begin value unconditionally

Example fix

# before
task --output prefixed --output-group-begin "=== "

# after
task --output group --output-group-begin "=== "
Defensive patterns

Strategy: validation

Validate before calling

if flags.Output.Name != "group" && flags.Output.Group.Begin != "" {
	return errors.New("--output-group-begin requires --output=group")
}

Try / catch

if err := flags.Validate(); err != nil {
	if strings.Contains(err.Error(), "--output-group-begin") {
		fmt.Fprintln(os.Stderr, "add --output=group or drop --output-group-begin")
		os.Exit(2)
}
	return err
}

Prevention

When it happens

Trigger: Running `task --output-group-begin <str>` without also passing `--output=group`, i.e. Output.Group.Begin is non-empty while Output.Name != "group".

Common situations: Adding group tuning flags to a command that already sets --output interleaved or prefixed; DOTENV/env-var config (TASK_X_OUTPUT_GROUP_BEGIN style) leaking into a non-group output setup.

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/5e543a1e195b2ee7. Report an issue: GitHub.