# Why does LuaLaTeX's \IfFileExists fail where XeLaTeX succeeds?

I have a series of files that I've been compiling with XeLaTeX. I recently attempted to compile with LuaLaTex and it made a royal mess of things. I traced the issue to the use of \IfFileExists in one of my macros. The bash script that is handling compile jobs out of the queue is doing a number of things such as retrieving and formatting LilyPond files for inclusion it the TeX document. If it is able to get everything together it creates a flag file in the build directory so TeX knows it can go ahead with processing music at that point.

This MWE acts as expected in XeLaTex but fails in LuaLaTex even when the file exists:

\documentclass{minimal}

\begin{document}

Song XX:

\IfFileExists{XX-has-music}{%
Typeset block for when music exists.
}{%
Typeset block for when music doesn't exist.
}

\end{document}


LuaLaTex doesn't seem to have a problem with file paths as even running \input on things in the same directory shows that it can find things there. What's going on?

The LuaLaTeX engine makes some assumptions about file names that XeLaTeX does not. In particular it assumes that all files should have a file extension segment following a period and that if such an extension is not otherwise specified that it must be .tex.
Based on this assumption it is munging the file name and the check \IfFileExists{XX-has-music} is actually executing something like \IfFileExists{XX-has-music.tex} and failing to find the file. The solution to make LuaLaTeX happy is to include at least one period in all file names. Even adjusting this example to use the filename XX.has-music will compile in either engine.
• Thanks @UlrikeFischer. I looked really hard for information about this, but I didn't figure out until after I'd already written this question and was trying to come up with an MWE that it had to do with file extensions (it was actually filecontents behavior that tipped me off) thus my searching was ineffective and I didn't turn up any of that. Hopefully this post might save somebody else the same journey. Mar 24 '15 at 8:41