Matched signals
- CRLF will be replaced by LF
- LF will be replaced by CRLF
- \r.*no such file or directory
- bad line endings
- unexpected carriage return
- ': command not found
- \r': No such file
- syntax error near unexpected token
Line ending mismatch (CRLF vs LF)
What this failure means
A script or source file contains Windows-style CRLF line endings where Unix LF endings are expected. On Linux CI runners this causes shell scripts to fail with cryptic “command not found” or “bad interpreter” errors because the carriage return character becomes part of the command or path.
Symptoms
Faultline looks for one or more of these log fragments:
CRLF will be replaced by LF
LF will be replaced by CRLF
\r.*no such file or directory
bad line endings
unexpected carriage return
': command not found
\r': No such file
syntax error near unexpected token
Diagnosis
Git can silently convert line endings on checkout. When core.autocrlf is
true on a Windows development machine, files are committed with CRLF and
converted back on checkout locally but left as CRLF in the committed object if
the remote does not enforce normalization.
On Linux CI runners the raw bytes are used, turning #!/bin/bash\r into a
missing interpreter path.
Common symptoms:
- Shell scripts exit with
'\r': command not foundorbad interpreter - Python scripts fail with
SyntaxError: invalid syntaxat otherwise valid lines git diffshows no changes but files appear modified to the OS- Linters report unexpected character errors on every line
Fix steps
-
Identify the affected file:
file path/to/script.sh # reports "CRLF line terminators" cat -A path/to/script.sh | head # shows ^M at line ends -
Convert the file to LF endings:
# Using sed (in-place): sed -i 's/\r//' path/to/script.sh # Using dos2unix: dos2unix path/to/script.sh # Using tr: tr -d '\r' < input.sh > output.sh && mv output.sh input.sh -
Add or update
.gitattributesat the repo root to enforce normalization:# Normalize all text files to LF in the repository * text=auto eol=lf # Explicitly mark shell scripts *.sh text eol=lf *.bash text eol=lf # Windows-specific files can keep CRLF *.bat text eol=crlf *.cmd text eol=crlf -
Re-normalize the index after adding
.gitattributes:git add --renormalize . git commit -m "chore: normalize line endings to LF" -
On CI, verify the post-checkout state:
grep -rlU $'\r' . --include='*.sh' | head -20
Validation
- Re-run the failing script after conversion.
- Confirm
file script.shreports “ASCII text” or “UTF-8 text” without “CRLF line terminators”. - Run
grep -c $'\r' script.shand confirm it prints0.
Why it matters
Line ending issues fail silently in editors but break loudly in CI. A single
CRLF in a shell script produces an undebuggable command not found error
that looks like a PATH or permission problem, wasting significant diagnostic
time.
Prevention
- Commit a
.gitattributesfile that enforceseol=lffor all text files. - Add a CI lint step:
grep -rlU $'\r' . --include='*.sh'and exit non-zero if any results are returned. - Use
EditorConfigwithend_of_line = lfso all editors produce correct files at save time.
How Faultline detects it
Use faultline explain line-ending to see the full playbook.
faultline analyze build.log
faultline explain line-ending
Generated from playbooks/bundled/log/build/line-ending.yaml. Do not edit directly.