GoogleContainerTools/skaffold · error
unable to evaluate cli flags: %w
Error message
unable to evaluate cli flags: %w
What it means
When building the `docker build` argument list, each entry of the artifact's CliFlags is expanded with util.ExpandEnvTemplate, substituting environment variables into the user-provided flag string. If a flag references an undefined or malformed template variable, the error is wrapped as "unable to evaluate cli flags: %w". This is a configuration error in the skaffold artifact definition, not a Docker problem.
Source
Thrown at pkg/skaffold/docker/image.go:691
if v == nil {
args = append(args, k)
} else {
args = append(args, fmt.Sprintf("%s=%s", k, *v))
}
}
for _, host := range a.AddHost {
args = append(args, "--add-host", host)
}
for _, from := range a.CacheFrom {
args = append(args, "--cache-from", from)
}
for _, cliFlag := range a.CliFlags {
cliFlag, err := util.ExpandEnvTemplate(cliFlag, env)
if err != nil {
return nil, fmt.Errorf("unable to evaluate cli flags: %w", err)
}
args = append(args, cliFlag)
}
if a.Target != "" {
args = append(args, "--target", a.Target)
}
if a.NetworkMode != "" {
args = append(args, "--network", strings.ToLower(a.NetworkMode))
}
if a.NoCache {
args = append(args, "--no-cache")
}
if a.Squash {
args = append(args, "--squash")View on GitHub (pinned to a1189de023)
Solutions
- Export the referenced environment variable before running skaffold (`export MY_VAR=...`).
- Fix the variable name in the skaffold.yaml cliFlags — check for typos against the actual env.
- Remove invalid template syntax from the flag string (stray `{{`/`}}`).
- Provide a default in the flag value or set the variable in CI pipeline configuration.
Example fix
// before (skaffold.yaml)
cliFlags: ["--build-arg", "TOKEN={{.MISSING_TOKEN}}"]
// after
cliFlags: ["--build-arg", "TOKEN={{.TOKEN}}"]
# with: export TOKEN=abc123 Defensive patterns
Strategy: validation
Validate before calling
// expand the same templates locally before invoking the build
for _, f := range artifact.CliFlags {
if _, err := util.ExpandEnvTemplate(f, env); err != nil {
return fmt.Errorf("cli flag %q needs env vars that are unset: %w", f, err)
}
} Prevention
- Document required env vars for cliFlags and set them in CI pipelines.
- Grep skaffold.yaml for `{{` templates and cross-check each name with the environment.
- Provide defaults for optional variables instead of bare references.
- Run skaffold diagnose / a dry parse before long builds.
When it happens
Trigger: A build artifact's `cliFlags` (dockerfile buildArgs section) contains an env-template like `{{.MY_VAR}}` or `$MY_VAR` where MY_VAR is unset in the environment, or the template syntax itself is invalid.
Common situations: CI environment missing a variable that exists locally, typo in the variable name inside cliFlags, leftover `{{` syntax from copy-paste, variable only defined in a shell profile that the skaffold process doesn't inherit.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- retrieving debug helpers registry: %w
- normalizing dockerfile path: %w
- creating actiosn runner: %w
- unable to evaluate build args: %w
- %q running container image %q errored during run with status
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/46d5aff39ee0ca49.
Report an issue: GitHub.