hashicorp/terraform · error

No '=' value in arg: %s

Error message

No '=' value in arg: %s

What it means

Thrown by FlagStringKV.Set when parsing a -var argument that does not contain '='. FlagStringKV splits each token on the first '=' into key/value; without one it cannot form a pair, so the whole token is rejected. This powers -var key=value for primitive values (distinct from -var-file).

Source

Thrown at internal/command/flag_kv.go:23

import (
	"fmt"
	"strings"
)

// FlagStringKV is a flag.Value implementation for parsing user variables
// from the command-line in the format of '-var key=value', where value is
// only ever a primitive.
type FlagStringKV map[string]string

func (v *FlagStringKV) String() string {
	return ""
}

func (v *FlagStringKV) Set(raw string) error {
	idx := strings.Index(raw, "=")
	if idx == -1 {
		return fmt.Errorf("No '=' value in arg: %s", raw)
	}

	if *v == nil {
		*v = make(map[string]string)
	}

	key, value := raw[0:idx], raw[idx+1:]
	(*v)[key] = value
	return nil
}

View on GitHub (pinned to d32a084675)

Solutions

  1. Provide key=value in the same token: `-var environment=prod`.
  2. Quote the whole pair if the value has spaces: `-var "name=John Doe"`.
  3. If the value is genuinely empty, include the '=': `-var foo=`.
  4. For many variables, use -var-file with a .tfvars file instead.

Example fix

// before
//   terraform plan -var environment
// after
//   terraform plan -var environment=prod
// or with spaces:
//   terraform plan -var "owner=John Doe"
Defensive patterns

Strategy: validation

Validate before calling

func validateVarToken(raw string) error {
    if !strings.Contains(raw, "=") {
        return fmt.Errorf("-var requires key=value; got %q", raw)
    }
    return nil
}

Prevention

When it happens

Trigger: Passing `-var myvar` (no value), `-var myvar=` (empty value is actually OK — '=' present), or any -var token lacking an '=' separator. Also triggered by misuse like `-var 'myvar'` expecting a prompt.

Common situations: Forgetting the value; using a space instead of '=' (shell then splits the value into a separate arg); quoting mistakes; expecting interactive variable entry where none is configured.

Related errors


AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11). Data as JSON: /api/errors/e2e1aa3094eee98e. Report an issue: GitHub.