The situation and the issue

When I launch pdflatex from another program, programatically, it seems that, even with the option -shell-escape, I am not able to launch gnuplot.

I have asked to specialists about my program environment (how should I launch pdflatex programatically in a proper way?) and it seems that I have to ask some advice to the LaTeX community. This question could also be asked on stackoverflow, but it seems that the solution would come more likely from someone who knows/understands how gnuplot is launched by pdflatex.


  • Is there a command line option to pdflatex to tell it where to find gnuplot?
  • Do you understand what is going on? Is it a problem with $PATH or something like that?
  • Do you know how can I fix the situation?

Log from pdflatex

Here are parts of the log from pdflatex: enter image description here enter image description here

Log from my program

My program prints also the following message

sh: gnuplot: command not found

More details

My programing environment is cocoa and here is how I launch pdflatex:

NSTask * myTask ;

myTask = [[NSTask alloc] init];

NSArray * arguments = @[@"-shell-escape",
                        nameLatexFile] ;

[myTask setCurrentDirectoryPath:[URLOfTheFolder path]];
[myTask setLaunchPath:@"/usr/texbin/pdflatex"];
[myTask setArguments:arguments];

[myTask launch];

Edit, answer to comments

  • $ gnuplot -V gives gnuplot 4.6 patchlevel 5
  • Shouldn't it be --shell-escape with two dashes?
    – Alexis
    Apr 11, 2014 at 6:49
  • so if you type gnuplot on the command line (without latex) does it start or does the shell still not find it? Apr 11, 2014 at 7:02
  • @Alexis no all pdftex command line arguments can be used with one or two dashes Apr 11, 2014 at 7:04
  • From command line/prompt, type gnuplot -V. Does it return the version of gnuplot?
    – user11232
    Apr 11, 2014 at 7:39
  • It seems that PATH is not propagated to this environment at all which is why you need the full path to pdflatex, as such it's a general programming question rather than TeX and probably off topic here, see for example this on StackOverflow stackoverflow.com/questions/208897/… (and others; I just searched for setLaunchPath in google) Apr 11, 2014 at 8:14

1 Answer 1


When you launch a binary from NSTask, it is not as if it had been launched from a terminal. Hence, there are no environment variables.

So, the solution is to give explicitly to the NSTask the environment.

Use: the method -setEnvironment: of NSTask.

You must log in to answer this question.

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