<div>The primitives \openin and \pdf* (\pdffilesize, \pdfximage, etc) behave slightly differently with regard to the path that they search.<br></div><div><br></div><div>\openin always checks the output directory specified by -output-directory option of pdftex and if it fails to find the file there, it tries to search the regular TEXINPUT path.<br></div><div><br></div><div>This causes problems with the Latex package graphicx. Below is the bugreport that I sent to the Latex maintainers and they advised me to report it to the TexLive maintainers.<br></div><div><br></div><div>There is a bug in the graphicx package which prevents \includegraphics from including a valid image which is located in the graphics path. The bug show up when the following conditions are met:<br></div><div><br></div><div>- We are using pdflatex on Linux.<br></div><div>- An directory is listed in \graphicspath, in the example below it is /root/texout/<br></div><div>- That directory contains a valid .pdf file, in the example below it is myimg.pdf<br></div><div>- The \includegraphics macro includes an image specified by its filename only (with or without an extension). In our example it is called "myimg" (without the double quotes).<br></div><div>- The compiled tex file is placed in a directory which is different from the directory that contains the image file and the current directory is not an ancestor directory of the directory with the image file.<br></div><div>  In our example the .tex file is in /root/archive/downloads/zzz/graphics_bug.tex.<br></div><div>- When we invoke pdflatex our current directory is the directory that contains the tex file. In our case the current directory is /root/archive/downloads/zzz/<br></div><div>- pdflatex is run from a current directory<br></div><div>- The directory that contains the .pdf file is specified as an output directory of pdflatex. In our case the pdflatex is invoked as:<br></div><div>  pdflatex -output-directory=/root/texout/ ./graphics_bug.tex<br></div><div><br></div><div>This is the sample file located in /root/archive/downloads/zzz/graphics_bug.tex<br></div><div>-----------------------------<br></div><div>\RequirePackage{latexbug}<br></div><div>\documentclass{article}<br></div><div>\usepackage[utf8]{inputenc}<br></div><div>\usepackage[T1]{fontenc}<br></div><div>\usepackage{graphicx}<br></div><div>\begin{document}<br></div><div>\graphicspath{{/root/texout/}}<br></div><div>\includegraphics{myimg}<br></div><div>\end{document}<br></div><div>-----------------------------<br></div><div><br></div><div>pdflatex should be able to find and include successfully the file myimg.pdf, but instead it shows the following error:<br></div><div>-------------------------------------------------------------------------------------<br></div><div>! Package pdftex.def Error: File `myimg.pdf' not found: using draft setting.<br></div><div><br></div><div>See the pdftex.def package documentation for explanation.<br></div><div>Type  H <return>  for immediate help.<br></div><div>...<br></div><div><br></div><div>l.8 \includegraphics{myimg}<br></div><div>-------------------------------------------------------------------------------------<br></div><div><br></div><div>If we run pdflatex without the -output-directory argument, then the file is compiled successfully:<br></div><div><br></div><div>-------------------------------------------------------------------------------------<br></div><div>Output written on graphics_bug.pdf (1 page, 8989 bytes).<br></div><div>Transcript written on graphics_bug.log.<br></div><div>-------------------------------------------------------------------------------------<br></div><div><br></div><div>This bug is caused by the fact that \includegraphics uses \IfFileExists which in turn uses \openin which is able to find graphics_bug.pdf in the output directory even if it is not specified in the .tex search path, but the corresponding \pdffilesize and \pdfximage are not able to find it.<br></div><div><br></div><div>You can see the full discussion here <a href="https://github.com/latex3/latex2e/issues/145">https://github.com/latex3/latex2e/issues/145</a> and why the Latex developers think it is an issue in TexLive and should be fixed there.<br></div><div><br></div><div>The attached patch fixes this bug for the pdf backend. Most likely the other backends have similar problems but they are not fixed by this patch.<br></div><div><br></div>