I need to run latex from command line for a project on OS X. LaTeX is installed in:


in the bin folder there are three folders:


both "universal-darwin" and "x86_64-darwin" have the executable file "latex". I ran this line in both of these directories and received the same error.

./latex /Users/fluid/Desktop/sample.tex

Here is the error

fluid:x86_64-darwin fluid$ ./latex /Users/fluid/Desktop/sample.tex
This is pdfTeX, Version 3.1415926-1.40.11 (TeX Live 2010)
restricted \write18 enabled.
entering extended mode
! I can't write on file `sample.log'.
(Press Enter to retry, or Control-D to exit; default file extension is `.log')
Please type another transcript file name:

and here is the file sample.tex

Sample \LaTeX{} file
Here is an equation
f(x) = e^x

How can I make this work?

  • @Fluid, There is however an alternative to run the file with TeXworks that comes with MacTeX. It's been running fine on my MBP. Your code works there. I just tried it. I never try on terminal.
    – Khaaba
    Sep 28, 2012 at 4:31
  • Welcome to TeX.SE. Sep 28, 2012 at 4:54
  • 1
    What does the terminal answer after you issue "echo $PATH"? (Without the quotes)
    – egreg
    Sep 28, 2012 at 6:26
  • @Mico: I think your comment should be an answer.
    – mpg
    Sep 28, 2012 at 6:28

1 Answer 1


You shouldn't invoke latex (or pdflatex) from the folder that contains the executables, because that folder is (or at least should be...) writeable only by root. Thus, latex has to crash because it can't create the .log, .aux, and .pdf (or .dvi) files to the executables folder. You may verify this by typing

sudo ./latex /Users/fluid/Desktop/sample.tex 

from within the executables folder, viz., /usr/local/texlive/2010/bin/x86_64-darwin: you'll be prompted for the superuser password, and thereafter latex should run without further complaints of the type you report in your posting. BTW, I really don't recommend doing this (i.e., running latex with superuser privileges) on a regular basis.

Assuming MacTeX was installed correctly, the TeX executables should be in the search path, and you should simply be running latex from the folder that contains the .tex file -- in the case you report, the Desktop folder.

By the way, you may want to think about updating your TeX distribution to MacTeX 2012.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .