Does \InputIfFileExists not work anymore?

TL;DR: You're actually looking for

\IfFileExists{/Mac/path/macros.tex}%
  {\input{/Mac/path/macros.tex}}
  {\input{/linux/path/macros.tex}}

The macro \InputIfFileExists{<file>}{<true>}{<false>} takes three arguments: the file to check the existence of, the <true> code to execute before inputting the file in case it is found and the <false> code to execute if the file doesn't exist. The way you're using it makes me think you're actually looking for \IfFileExists, which is why it works when you switch to that notation.

In your usage

\InputIfFileExists{/Mac/path/macros.tex}%
  {\input{/Mac/path/macros.tex}}
  {\input{/linux/path/macros.tex}}

\InputIfFileExists{<one>}{<two>}{<three>} checks for the existence of <one>. If it exists, it will necessarily execute \input{<one>}. So, if /Mac/path/macros.tex exists, you'll actually end up trying to \input{/Mac/path/macros.tex} twice.

The code \input{/linux/path/macros.tex} will be executed when the file <one> doesn't exist.


If the only reason for conditioning on the path stems from a choice of your operating system, you might be interested in looking at the ifplatform package. See Is there a macro telling which OS we're using?.


There has been no change to \InputIfFileExists since 1995/05/25 so unless you have not upgraded for a long time the system upgrade is probably unrelated.

However a better, more portable, and more efficient, markup here would be

\documentclass{amsart}
  \input{macros}
\begin{document}
text
\end{document}

or better still rename macros.tex to macros.sty and use

\documentclass{amsart}
  \usepackage{macros}
\begin{document}
text
\end{document}

Just as you do not have to give the full path to amsart.cls and then customise that path on every machine, you should not have to give the full path to locally produced files.

You just need to ensure that macros.tex (or macros.sty) is in the TEXINPUTS path, either by adding the location to the standard path or putting the files into a standard place. So on linux texlive ~/texmf/tex/latex/mymacros/macro.sty would work by default for example (kpsexpand '$TEXMFHOME' will show the value of TEXMFHOME but it defaults to $HOME/texmf)

Tags:

Conditionals