[Tex/LaTex] Output-directory can’t write on file log, linux terminal

outputpdftex

I'm trying to run pdflatex on a specific file stored in ~/path/template.tex, now I also want to have the output be in the same path. Note that I'm currently working in another path (Not the root).

So I'm currently in the directory ~/workspace/ and issue the following command:

pdflatex -output-directory=~/path/ ~/path/template.tex

However this is giving me the following error:

! I can't write on file `template.log'.
(Press Enter to retry, or Control-D to exit; default file extension is `.log')
Please type another transcript file name: 
! Emergency stop
!  ==> Fatal error occurred, no output PDF file produced!

Does anybody know how to fix this issue?

I saw some people write, that it could be because of another process using pdflatex, or because the template.log is already being written to. But this does not seem to be the case here, I have checked for other processes being run. Also note that it can find the template.tex, and more importantly I can run pdflatex from the root of my computer without issues.

Best Answer

Under normal settings, TeX binaries don't allow writing files specified with absolute paths or above the working directory. The -output-dir option allows to specify a directory below the working one.

This is for security; it can be changed, but I'd avoid doing it.

A standard method with Unix shells is

(cd ~/path ; pdflatex template)
Related Question