GitHub Actions "Unable to process file command env" (multiline secret to GITHUB_ENV)
Writing to GITHUB_ENV uses NAME=value lines. A value containing newlines (a PEM key, a multiline secret) breaks that format and must use the heredoc syntax instead.
What this error means
A run step appending a multiline value to GITHUB_ENV fails with "Unable to process file command 'env' successfully", typically when the value is a multiline secret.
github-actions
Error: Unable to process file command 'env' successfully.
Error: Invalid format '-----BEGIN PRIVATE KEY-----'Common causes
Multiline value without a delimiter
A value with embedded newlines was written as NAME=value, so the lines after the first are treated as malformed commands.
Secret with newlines piped directly
A multiline secret was echoed straight into GITHUB_ENV without heredoc framing.
How to fix it
Use heredoc syntax for multiline env values
- Write the value with a unique heredoc delimiter.
- Ensure the delimiter does not appear inside the value.
- Prefer passing secrets via env: on the step when possible.
.github/workflows/ci.yml
- run: |
{
echo "PRIVATE_KEY<<EOF"
echo "${{ secrets.PRIVATE_KEY }}"
echo "EOF"
} >> "${GITHUB_ENV}"How to prevent it
- Always use heredoc framing for multiline GITHUB_ENV values.
- Pick a delimiter guaranteed not to appear in the value.
- Pass secrets through step-level env where you can.
Related guides
GitHub Actions Heredoc in a run: Step Breaks or Expands VariablesFix GitHub Actions heredocs in run: steps - a quoted vs unquoted delimiter changes variable expansion, and in…
GitHub Actions "Can't add a heredoc delimiter that appears in the value"Fix GitHub Actions "matching delimiter not found" / heredoc delimiter collision when writing a multiline valu…
GitHub Actions "Unable to process file command 'env' ... Invalid format"Fix GitHub Actions "Unable to process file command 'env' successfully ... Invalid format" - a multiline value…