or
Caleb
luatex
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?
Top Answer
Caleb
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.
Why does LuaLaTeX's \IfFileExists fail where XeLaTeX succeeds?
Caleb
Imported this Q from [here](https://tex.stackexchange.com/q/234750/5100), also [this feature request](https://topanswers.xyz/meta?q=346) to keep back-links to posts on import.