Skip to content
Latchkey

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

  1. Write the value with a unique heredoc delimiter.
  2. Ensure the delimiter does not appear inside the value.
  3. 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →