Pdflatex not found despite being installed and in the PATH

Problem description

Under Ubuntu (18.04 LTS and on another machine with 20.04 LTS, both give same result):
I have installed GNU Octave using apt.
In both installations, despite having texlive-latex-base (and texlive-latex-recommended) correctly installed and in the PATH, when I try to publish in PDF format with:

octave:1> publish ("myscript.m", "pdf")

It returns the following error and only publish a .tex file in an html/ directory:

sh: 1: pdflatex: not found
ans = /home/fabio/path/to/my/project/html/myscript.tex

Can someone have an Idea why Octave doesn’t seem to be able to find the pdflatex command ??
Maybe it’s because pdflatex is actually a symlink to pdftex ?? But if it is the reason, how can I overcome this?

My system

  • OS: Ubuntu 18.04 LTS or Ubuntu 20.04
  • Octave version: e.g. Version 5.2.0-1
  • Installation method: sudo apt install octave

Thanks in advance. I’ve already spent dozens of hours trying to find out what’s going on here, and even the allmighty stackoverflow seems to be unaware of this problem…

Even though you used apt, in recent Ubuntu versions Octave can be installed via snap, see some random web-searched article which covers the basics, as it might apply to other software on your system too:

To verify if Octave has been installed via snap, type:

snap list

There are long discussions regarding the pros and cons of snaps / flatpaks / …

The problem in your case seems to be that a snap is a software (e.g. GNU Octave) bundled in a “lightweight” container (like running your software with Docker). From within the Octave container, you cannot “see” your “real” Ubuntu system, where you probably have installed pdfLaTeX more than correctly :+1:

Long story short. Try to use the publish “latex”-output format

publish ("myscript.m", "latex")

and create the final PDF from your Ubuntu terminal:

$ cd html
$ pdflatex myscript.tex

You’re right… despite the fact that I installed it with apt, Octave was in a snap container…
I did uninstall and build Octave manually, and now publish works fine with the pdf format.