golang/go · error
evaluating condition %q: %w
Error message
evaluating condition %q: %w
What it means
Engine.conditionsActive wraps any error returned by a Cond's Eval method with the condition tag (engine.go:537-539). The inner %w error is typically one of the 'unrecognized GOOS/GOARCH/compiler/GOEXPERIMENT' errors, indicating the suffix value is syntactically valid (known prefix) but the value itself is invalid.
Source
Thrown at src/cmd/internal/script/engine.go:538
if impl == nil {
return false, fmt.Errorf("unknown condition prefix %q; known: %v", prefix, slices.Collect(maps.Keys(e.Conds)))
}
if !impl.Usage().Prefix {
return false, fmt.Errorf("condition %q cannot be used with a suffix", prefix)
}
} else {
impl = e.Conds[cond.tag]
if impl == nil {
return false, fmt.Errorf("unknown condition %q", cond.tag)
}
if impl.Usage().Prefix {
return false, fmt.Errorf("condition %q requires a suffix", cond.tag)
}
}
active, err := impl.Eval(s, suffix)
if err != nil {
return false, fmt.Errorf("evaluating condition %q: %w", cond.tag, err)
}
if active != cond.want {
return false, nil
}
}
return true, nil
}
func (e *Engine) runCommand(s *State, cmd *command, impl Cmd) error {
if impl == nil {
return cmdError(cmd, errors.New("unknown command"))
}
async := impl.Usage().Async
if cmd.background && !async {
return cmdError(cmd, errors.New("command cannot be run in background"))
}View on GitHub (pinned to b6b368adc5)
Solutions
- Read the wrapped inner error to identify which value is unrecognized.
- Fix the suffix to a valid value for that condition (see KnownOS/KnownArch/buildcfg experiment list).
- If the value was removed in a newer Go version, gate the line behind a version check or remove it.
Example fix
// before [GOOS:macos] exec go build // -> evaluating condition "GOOS:macos": unrecognized GOOS "macos" // after [GOOS:darwin] exec go build
Defensive patterns
Strategy: try-catch
Try / catch
// errors.Is / errors.As on the wrapped chain to distinguish cause.
if errors.Is(err, something) { ... }
// The inner error after 'evaluating condition %q:' reveals the rejected value. Prevention
- Treat this wrapper as a pointer to the inner 'unrecognized ...' error and fix the suffix value.
- Validate suffix values (GOOS/GOARCH/compiler/GOEXPERIMENT) before running the script.
When it happens
Trigger: Using [GOOS:linnux] — the prefix GOOS is known, so execution reaches the eval closure, which then rejects the unknown value 'linnux' and that error is wrapped here. Same for [compiler:gcc], [GOEXPERIMENT:bogus].
Common situations: Correct condition name but misspelled suffix value; experiment renamed across Go versions; using a value valid in one context but not the current build.
Related errors
- unrecognized GOOS %q
- unrecognized GOARCH %q
- unrecognized compiler %q
- %s:%d: %w
- unknown condition prefix %q; known: %v
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/8f241b934269d4a3.
Report an issue: GitHub.