1

I'm attempting to to get Latexmk working on a new computer running OSX Catalina. I've installed MacTeX and TeXworks. As far as I can tell, all of my settings are consistent with the settings on my old computer, where this worked fine. I can compile .tex documents fine (on the new computer) in TeXworks using the PDFLaTeX option. However, if I try and compile via Latexmk in TeXworks, it fails and I get the error:

Latexmk: applying rule 'pdflatex'...

sh: pdflatex: command not found

However, if I compile the .tex file using Latexmk via Terminal, there are no issues.

Weirdly, if I open TeXworks via Terminal (instead of from Applications), the Latexmk compile option in TeXworks compiles without any issues.

I would love to figure out why I am unable to compile using Latexmk.

Other information that might be relevant:

$ which pdflatex returns /usr/local/bin/pdflatex

$ which latexmk returns /Library/TeX/texbin/latexmk

Both of these paths are present in TeXworks Preferences > Typesetting > Paths for TeX and related programs.

$ echo $PATH returns /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin

This is version 4.70b of Latexmk.

SOLVED: Added the paths in TeXworks Preferences > Typesetting > Paths in the TeXworks that was opened via Terminal. The TeXworks opened via Applications is now able to compile via latexmk.

See below comment by John Collins for another solution.

2
  • Could you somehow be having more than one TeXworks installation? Oct 21, 2020 at 7:07
  • It's definitely not a problem with more than one TeXworks installation. I can both reproduce the problem on my computer that has a single installation and work around it. See my answer for details. Oct 23, 2020 at 16:58

1 Answer 1

1

The problem happens because the current version of TeXworks doesn't give a suitable value to the PATH environment variable to programs it invokes. This may change in a future version. In contrast, at the command line, PATH does have a suitable value, which the installation of MacTeX arranges to happen.

Possible solutions:

  1. Use TeXShop instead of TeXworks. In TeXShop, latexmk works and is supported.

  2. Configure latexmk by having one of its latexmkrc files set PATH suitably. A very simple-minded solution is to add the following line to a latexmkrc file:

     $ENV{PATH} .= ':/Library/TeX/texbin';
    

Fancier solutions are possible.

You must log in to answer this question.

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