# Inputting extension-less files with LuaTeX fails after recent LaTeX update

After the recent (last week) LaTeX update, inputting extension-less files in LuaTeX fails.

The workarounds in Error with LuaLaTeX, tcolorbox with the listings library and an extension-less file don't work anymore, as in the following MWE:

\documentclass{minimal}
\usepackage{listings}
\begin{document}
\lstinputlisting{{test}}
\end{document}


Compilations fails with the following error message:

! Package Listings Error: File {test}(.tex)' not found.


It compiles OK when reverting the LaTeX update.

I could add a phony extension to my files but I'd rather not.

Is there a way to input extension-less files with LuaTeX after the LaTeX update?

• we will fix this in the next latex release, but I added a working version to my answer – David Carlisle Oct 10 '19 at 10:02
• This is most useful. Thanks a lot David! – Marc Baudoin Oct 10 '19 at 10:19

The following workaround makes the version without extra braces work in luatex and pdftex

\documentclass{minimal}
\usepackage{listings}
\makeatletter
\ifx\directlua\@undefined\else
\long\def \IfFileExists@#1#2#3{%
\openin\@inputcheck{#1}%
\ifeof\@inputcheck
\ifx\input@path\@undefined
\def\reserved@a{#3}%
\else
\def\reserved@a{\@iffileonpath{#1}{#2}{#3}}%
\fi
\else
\closein\@inputcheck
\edef\@filef@und{#1 }%
\def\reserved@a{#2}%
\fi
\reserved@a}
\long\def\@iffileonpath#1{%
\let\reserved@a\@secondoftwo
\expandafter\@tfor\expandafter\reserved@b\expandafter
:\expandafter=\input@path\do{%
\openin\@inputcheck{\reserved@b#1}%
\ifeof\@inputcheck\else
\edef\@filef@und{\reserved@b#1 }%
\let\reserved@a\@firstoftwo%
\closein\@inputcheck
\@break@tfor
\fi}%
\reserved@a}
\fi
\makeatother
\begin{document}

\lstinputlisting{test}

\end{document}


This is a non answer, to collect possible changes to make this work again, the example can be simplified to this test file

If there is a file test in the current directory (mine just has the text hello) then this plain tex

\newread\tst
\openin\tst=test

\ifeof\tst
\show Y\else \show N
\fi
\bye


with texlive 2019 luatex

$luatex cc245 This is LuaTeX, Version 1.10.0 (TeX Live 2019) restricted system commands enabled. (./cc245.tex > the letter Y.  with texlive 2019 pdftex $ pdftex cc245
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=pdftex)
restricted \write18 enabled.
entering extended mode
(./cc245.tex
> the letter N.


This is not a recent change to luatex, a 2017 luatex also produces

\$ /usr/local/texlive/2017/bin/x86_64-cygwin/luatex cc245
This is LuaTeX, Version 1.0.4 (TeX Live 2017)
restricted system commands enabled.
(./cc245.tex
> the letter Y.


But despite the different behaviour here the old latex code more or less accidentally ended up including the file but the new one sees the ifeof true and so doesn't load the file.

We can probably detect this now we can see the behaviour but I can't suggest an immediate fix just now.

This version works the same way in luatex (and points teh way to getting consistent behaviour in latex)

\newread\tst
\ifx\directlua\undefined
\openin\tst=test
\else
\openin\tst={test}
\fi

\ifeof\tst
\show Y\else \show N
\fi
\bye
`
• It works like a charm. Thanks David! – Marc Baudoin Oct 10 '19 at 10:19