go-task/task · error

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

Error message

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

What it means

Flag validation error raised by the Validate function after CLI parsing before task execution. It fires when --output-group-end (end marker for grouped output) is given while the output mode is not 'group', making the marker meaningless. Fix by adding --output=group or removing --output-group-end.

Source

Thrown at internal/flags/flags.go:221

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 {
		return errors.New("task: --no-status only applies to --json with --list or --list-all")
	}

View on GitHub (pinned to 385e5ad92a)

Solutions

  1. Add `--output=group` to the command
  2. Remove --output-group-end if group output is not wanted
  3. Audit scripts/env for a globally exported group-end value

Example fix

# before
task --output interleaved --output-group-end "=== END"

# after
task --output group --output-group-end "=== END"
Defensive patterns

Strategy: validation

Validate before calling

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

Try / catch

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

Prevention

When it happens

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

Common situations: Copy-pasted command lines where the --output=group part was dropped; scripts exporting group-output env vars globally for all task invocations.

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