urfave/cli · error

sufficient count of arg %s not provided, given %d expected %

Error message

sufficient count of arg %s not provided, given %d expected %d

What it means

After consuming values, ArgumentsBase.Parse checks count < a.Min and returns this error naming the argument, how many values were given, and the required minimum. It means the user supplied too few values for a required positional argument.

Source

Thrown at args.go:229

	var vc VC
	var t T
	value := vc.Create(a.Value, &t, a.Config)
	a.values = []T{}

	tracef("attempting arg%[1] parse", &a.Name)
	for _, arg := range s {
		if err := value.Set(arg); err != nil {
			return s, fmt.Errorf("invalid value %q for argument %s: %v", arg, a.Name, err)
		}
		tracef("set arg%[1] one value", &a.Name, value.Get().(T))
		a.values = append(a.values, value.Get().(T))
		count++
		if count >= a.Max && a.Max > -1 {
			break
		}
	}
	if count < a.Min {
		return s, fmt.Errorf("sufficient count of arg %s not provided, given %d expected %d", a.Name, count, a.Min)
	}

	if a.Destination != nil {
		tracef("appending destination")
		*a.Destination = a.values // append(*a.Destination, a.values...)
	}

	return s[count:], nil
}

func (a *ArgumentsBase[T, C, VC]) Get() any {
	if a.values != nil {
		return a.values
	}
	return []T{}
}

type (

View on GitHub (pinned to 1a4deb4f5a)

Solutions

  1. Supply at least Min values on the command line: the message states exactly how many were given and expected.
  2. Quote multi-word values individually so shell word-splitting preserves each argument.
  3. Check for empty environment variables being dropped in scripted invocations; guard with "${VAR:?}".

Example fix

// before
myapp copy src/          # Min: 2
// after
myapp copy src/ dst/
Defensive patterns

Strategy: validation

Validate before calling

minRequired := 2
given := len(positionalArgs)
if given < minRequired {
	return fmt.Errorf("need %d positional args, got %d", minRequired, given)
}

Try / catch

if err := cmd.Run(ctx, os.Args); err != nil {
	if strings.Contains(err.Error(), "sufficient count of arg") {
		fmt.Fprintf(os.Stderr, "usage error — too few arguments: %v\n", err)
		os.Exit(2)
	}
	return err
}

Prevention

When it happens

Trigger: Invoking a command whose argument declares Min > 0 (e.g. cli.Args{Min: 2}) with fewer than Min tokens on the command line.

Common situations: Forgetting a required argument in scripts/CI invocations, shell quoting collapsing what should be two values into one, or an empty shell variable vanishing from the command line.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of urfave/cli@1a4deb4f5a (2026-08-31). Data as JSON: /api/errors/9dc8c99e96e2f70f. Report an issue: GitHub.