Background information on my computing setup: MacBook Air (late-2019 model), MacOS 11.2.3 "Big Sur", MacTeX2021 with all updates current.
Consider the following MWE:
\documentclass{article}
%\obeylines
\begin{document}
abc
\end{document}
It (unsurprisingly) compiles fine under pdfLaTeX, XeLaTeX, and LuaLaTeX. In contrast, if one removes the % comment character before \obeylines, one gets the following error messages:
Under pdfLaTeX:
... (/usr/local/texlive/2021/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def ! Missing \endcsname inserted. <to be read again> ^^M l.29 {l3backend-pdftex.def}{2021-03-18}{}Under XeLaTeX:
(/usr/local/texlive/2021/texmf-dist/tex/latex/l3backend/l3backend-xetex.def ! Missing \endcsname inserted. <to be read again> ^^M l.29 {l3backend-xetex.def}{2021-03-18}{}Under LuaLaTeX:
... (/usr/local/texlive/2021/texmf-dist/tex/latex/l3backend/l3backend-luatex.def ! Missing \endcsname inserted. <to be read again>l.29 {l3backend-luatex.def}{2021-03-18}{}
Observe: no
^^Min the LuaLaTeX error message, unlike with the pdfLaTeX and XeLaTeX.
Aside: The Plain-TeX test document
\obeylines
abc
\bye
compiles fine under pdfTeX, XeTeX, and LauTeX.
Question: Is this a bug? A feature? Are there any known work-arounds? FWIW: I'm sure the test program compiles fine under MacTeX2020.


\obeylinesis not really a preamble command. Best case scenario it will mess up reading the.auxfile at\begin{document}, so if it worked before I'd say it was by accident – Phelype Oleinik Apr 14 '21 at 16:59\obeylinesin the preamble of a LaTeX document. – Mico Apr 14 '21 at 17:01l3backendfiles could be changed to cope with that setting (adding two%at the end of the first two non-comment lines), and this MWE will work again, but I'd advise you to not trust that other code will be so tolerant. As a rule of thumb catcode changes (and in this case\endlinecharchanges) should better be restricted to the document body (and preferrably enclosed in a group) – Phelype Oleinik Apr 14 '21 at 17:08luatexdoesn't show^^Mas the token to be read again, which seems a “feature”. – egreg Apr 14 '21 at 17:18luatexrenders the actual ASCII 13 on the terminal, rather than the^^Mnotation (which is not too helpful in this case) – Phelype Oleinik Apr 14 '21 at 17:23\catcode`\^^M=15, the error message shows^^Mas the invalid character also withluatex. – egreg Apr 14 '21 at 17:33\obeylinesis npt documented in the LaTeX manual or the companion or any other official documentation. So it isn't a LaTeX command. – Martin Schröder Apr 14 '21 at 21:10\obeylinesis defined inlatex.ltx(in a way that's entirely analogous to its definition on p. 352 of the TeXbook); does that make it a LaTeX command? Anyway, as Phelype and others have already shown, the issue I was stumbling over was caused by me improperly running\obeylinesin the preamble instead of in the body ofdocumentenvironment. – Mico Apr 14 '21 at 21:21