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
- Write multiline values using a randomized heredoc delimiter that cannot appear in the content.
- Open with NAME<<DELIM, write the value, then close with DELIM on its own line.
- 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
GitHub Actions multiline output to GITHUB_OUTPUT without a delimiterFix the GitHub Actions error where a multiline step output written to GITHUB_OUTPUT with NAME=value syntax fa…
GitHub Actions GITHUB_ENV heredoc delimiter appears in the valueFix the GitHub Actions error where the heredoc delimiter you chose for GITHUB_ENV also appears inside the val…
GitHub Actions run step "syntax error near unexpected token"Fix the GitHub Actions run-step error "syntax error near unexpected token" in a multiline run block - usually…