Skip to content
Latchkey

bash "here-document delimited by end-of-file" in CI

bash never found the heredoc's closing delimiter, so it consumed the rest of the file as the document and warned that the heredoc was "delimited by end-of-file". The terminator must appear on its own line with no surrounding whitespace, unless you opened with <<-.

What this error means

A step warns "here-document at line N delimited by end-of-file (wanted `EOF')" and the commands after the heredoc silently became part of it, so they never ran.

bash
script.sh: line 5: warning: here-document at line 3 delimited by
end-of-file (wanted `EOF')

Common causes

The terminator is indented

A plain <<EOF requires the closing EOF at column zero. Leading spaces (common when the heredoc is inside an indented block) mean the terminator is not recognized.

The terminator is misspelled or missing

A typo (EOL vs EOF), a trailing space after EOF, or an entirely absent terminator makes bash read to the end of the file.

How to fix it

Place the terminator at column zero

The closing word must be alone on its line with no leading or trailing whitespace and spelled exactly like the opener.

bash
cat <<EOF > config.env
KEY=value
EOF

Use <<- to allow tab indentation

The <<- form strips leading tabs (not spaces) from the body and the terminator, so you can indent a heredoc inside a block with tabs.

bash
if true; then
	cat <<-EOF
	indented body
	EOF
fi

How to prevent it

  • Keep heredoc terminators unindented, or use <<- with tabs only.
  • Match the terminator spelling exactly, with no trailing space.
  • Run bash -n to catch an unterminated heredoc before it runs.

Related guides

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