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
- Provide key=value in the same token: `-var environment=prod`.
- Quote the whole pair if the value has spaces: `-var "name=John Doe"`.
- If the value is genuinely empty, include the '=': `-var foo=`.
- 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
- Always pass -var as a single key=value token.
- Quote the whole pair when the value has spaces.
- Prefer -var-file for many or complex variables.
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
- Too many command line arguments. Did you mean to use -chdir?
- Option -write cannot be used when reading from stdin
- No file or directory at %s
- at most 1 action can be invoked per operation
- Expected a single argument: NAME.
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/e2e1aa3094eee98e.
Report an issue: GitHub.