Skip to content
Latchkey

GitHub Actions env var with a newline breaks GITHUB_ENV parsing

The GITHUB_ENV file uses "NAME=value" lines. A value that contains a newline spills onto the next line, which the runner parses as a malformed entry and rejects.

What this error means

A step that appends to GITHUB_ENV fails with an invalid-format error, or later steps see a truncated value.

github-actions
Error: Unable to process file command 'env' successfully.
Error: Invalid format 'us-east-1 build output line 2'

Common causes

Multiline value with NAME=value syntax

Command output containing a newline written as "echo NAME=$(cmd) >> GITHUB_ENV" breaks the one-line-per-entry contract.

How to fix it

Use the heredoc delimiter syntax

  1. Write multiline values using a randomized heredoc delimiter that cannot appear in the content.
  2. Open with NAME<<DELIM, write the value, then close with DELIM on its own line.
  3. Re-run.
.github/workflows/ci.yml
- run: |
    {
      echo 'NOTES<<EOF'
      cat build-notes.txt
      echo 'EOF'
    } >> "${GITHUB_ENV}"

How to prevent it

  • Always use the heredoc form for values that may contain newlines.
  • Pick a delimiter unlikely to occur in the value, such as a random suffix.

Frequently asked questions

What causes ""env var with newline breaks parsing""?
Command output containing a newline written as "echo NAME=$(cmd) >> GITHUB_ENV" breaks the one-line-per-entry contract.
How do I fix "env var with newline breaks parsing"?
Use the heredoc delimiter syntax

Related guides

References

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