[Tex/LaTex] epstopdf and graphicspath with pdflatex


If I have an eps file in a subfolder and point to it with graphicspath, it can't seem to do the conversion, the log says:

(epstopdf)             Output file: </path/to/image/img-eps-converted-to.pdf>
(epstopdf)             Command: <repstopdf --outfile=/path/to/image/img-eps-converted-to.pdf /path/to/image/img.eps>
(epstopdf)             \includegraphics on input line 72.
runsystem(repstopdf --outfile=/path/to/image/img-eps-converted-to.pdf /path/to/image/img.eps)...executed safely (allowed).

Package epstopdf Info: Result file: </path/to/image/img-eps-converted-to.pdf>.

./chapters/results2.tex:72: Package pdftex.def Error: File `/path/to/image/img-eps-converted-to.pdf' not found.

If I run epstopdf --outfile=/path/to/image/img-eps-converted-to.pdf /path/to/image/img.eps it works fine. If I run the same command with repstopdf, it returns:

!!! Error: Output filename '/path/to/image/img-eps-converted-to.pdf' not allowed in restricted mode.

Running ls -ld /path/to/image returns:


Files for example:





%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 






%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 



Best Answer

Running external programs is a security risk. Therefore the default settings are a compromise. Some more or less secure programs (hopefully more "more") are allowed. This is called the restricted shell escape mode. epstopdf is too powerful, it can overwrite arbitrary files. Therefore, a restricted version repstopdf was created, which follows the policy of texmf.cnf, which restricts the writing of output files, from texmf.cnf of TeX Live 2015:

% Allow TeX \openin, \openout, or \input on filenames starting with `.'
% (e.g., .rhosts) or outside the current tree (e.g., /etc/passwd)?
% a (any)        : any file can be opened.
% r (restricted) : disallow opening "dotfiles".
% p (paranoid)   : as `r' and disallow going to parent directories, and
%                  restrict absolute paths to be under $TEXMFOUTPUT.
openout_any = p
openin_any = a

% Write .log/.dvi/etc. files here, if the current directory is unwritable.

In your case, the output file name starts with "/", thus it is an absolute file name and variable TEXMFOUTPUT is probably not set.

Possible solutions/workarounds:

  • Since the files are in sub folders of the current working directory, try relative file names instead.

  • TeX Live's epstopdf-sys.cfg as provided by the package author (me) sets the program name to repstopdf if restricted shell escape was detected. In case of full shell escape, epstopdf is used. Thus you can also run your project with pdflatex -shell-escape.