Skip to content
Latchkey

GitHub Actions "Unrecognized named-value: 'env'" in CI

Each workflow location exposes only certain contexts. Referencing env (or another context) in a place that does not provide it makes the expression compiler reject the file with "Unrecognized named-value".

What this error means

The run fails with "Invalid workflow file" and "(Line: N, Col: M): Unrecognized named-value: 'env'. Located at position 1 within expression: env.X".

GitHub Actions
Invalid workflow file: .github/workflows/ci.yml
(Line: 12, Col: 14): Unrecognized named-value: 'env'.
Located at position 1 within expression: env.DEPLOY

Common causes

env referenced where it is not in scope

The env context is not available in runs-on, in some job-level keys, or in concurrency evaluated before the job environment exists.

A typo treated as a context name

A misspelled context or a bare word inside ${{ }} is parsed as a named-value the compiler does not recognize.

How to fix it

Use a context that is available there

  1. Check the contexts allowed at that key in the GitHub docs.
  2. Replace env with vars, github, or a value passed in another way.
  3. Re-run the workflow.
.github/workflows/ci.yml
# instead of env in runs-on, use a matrix or vars
runs-on: ${{ matrix.os }}

Move the logic to a step where env exists

Read env inside a run step or a step-level if, where the env context is populated.

How to prevent it

  • Consult the context availability table before using a context.
  • Prefer vars/secrets for values needed at evaluation-sensitive keys.
  • Validate expressions in a schema-aware editor.

Frequently asked questions

What causes ""Unrecognized named-value: 'env'""?
The env context is not available in runs-on, in some job-level keys, or in concurrency evaluated before the job environment exists.
How do I fix "Unrecognized named-value: 'env'"?
Use a context that is available there

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card