Skip to content
Latchkey

GitHub Actions multiline run script fails (YAML block scalar)

Multiline run commands use a YAML block scalar (| keeps newlines, > folds them). Choosing > or mis-indenting lines folds or strips your script so the shell sees a different command than intended.

What this error means

A multiline run command behaves as one folded line, loses newlines, or fails with a shell syntax error after the YAML block scalar mangled it.

github-actions
# Using '>' folds newlines into spaces, breaking the script:
run: >
  echo one
  echo two   # becomes: echo one echo two

Common causes

Folded scalar (>) used for a script

> joins lines with spaces, collapsing separate commands into one.

Inconsistent indentation in the block

Mismatched indentation truncates or reshapes the script body.

How to fix it

Use the literal block scalar

  1. Use | (literal) to preserve newlines for multiline scripts.
  2. Indent every line of the block consistently under run.
  3. Reserve > for prose-like folding, not shell commands.
.github/workflows/ci.yml
- run: |
    echo one
    echo two
    ./build.sh

How to prevent it

  • Default to | for multiline run blocks.
  • Lint workflows so folded-scalar mistakes are caught.

Frequently asked questions

What causes "multiline run script fails"?
> joins lines with spaces, collapsing separate commands into one.
How do I fix multiline run script fails?
Use the literal block scalar

Related guides

References

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