Why Does This Error Happen?

When you set the interpreter to 'latex', GNU Octave doesn't render the LaTeX natively. Instead, it runs a background pipeline: it writes a small LaTeX snippet to a temporary file, compiles it using latex to a DVI file, and then converts that DVI to an image using either dvipng or dvisvgm. If any step in this pipeline fails during Octave's startup/runtime test, Octave disables the LaTeX interpreter entirely and throws the warning.

Step 1: Check for Environment Variable Typos

In your environment setup, you mentioned setting OCTAVE_DVISVG_BINARY. However, the correct environment variable name expected by Octave is actually OCTAVE_DVISVGM_BINARY (note the 'M' at the end, matching the dvisvgm binary name).

# Correct environment variables
export OCTAVE_LATEX_BINARY="/path/to/latex"
export OCTAVE_DVIPNG_BINARY="/path/to/dvipng"
export OCTAVE_DVISVGM_BINARY="/path/to/dvisvgm"

Step 2: Fix Environment Sourcing in Shebang Scripts

When you run an Octave script using a shebang like #!/usr/bin/octave, it runs in a non-interactive shell. This means your .bashrc or .bashenv files might not be sourced, meaning Octave won't see those environment variables at all!

To guarantee Octave finds the binaries regardless of how the script is executed, define them explicitly at the very beginning of your Octave script using setenv:

#!/usr/bin/octave

# Explicitly set paths inside the script
setenv("OCTAVE_LATEX_BINARY", "/usr/bin/latex");
setenv("OCTAVE_DVIPNG_BINARY", "/usr/bin/dvipng");
setenv("OCTAVE_DVISVGM_BINARY", "/usr/bin/dvisvgm");

fig = figure();
X = 1:1000;
plot(X);
xlabel('$x$', 'interpreter', 'latex');

Step 3: Check for Sandboxing (Flatpak / Snap)

If you installed Octave via Flatpak or Snap, it runs inside a sandboxed container. Even if TeX Live is installed on your host system, the sandboxed Octave cannot access host binaries like latex or dvipng.

  • Flatpak Solution: Install the TeX Live extension for Flatpak:
    flatpak install org.octave.Octave.texlive
  • Native Package Solution: If possible, install Octave and TeX Live using your system's native package manager (e.g., apt, pacman, or dnf) so they can seamlessly communicate.

Step 4: Verify /tmp Execution Permissions

Octave performs its LaTeX compilation in the system's temporary directory (usually /tmp). If your /tmp directory is mounted with the noexec option (a common security hardening practice on Linux), Octave will fail to run the generated LaTeX binary tests.

You can check if this is the case by running:

mount | grep /tmp

If you see noexec, you can instruct Octave to use a different temporary directory where execution is permitted by setting the TMPDIR environment variable before launching Octave:

export TMPDIR=$HOME/tmp
octave

Step 5: Manually Debug the Pipeline

If the error persists, you can manually run the compilation pipeline to see the exact error message that Octave is hiding:

  1. Create a file named test.tex containing:
    \documentclass{article}
    \begin{document}
    $x$
    \end{document}
  2. Run the following commands in your terminal:
    latex test.tex
    dvipng test.dvi
    dvisvgm test.dvi

This will reveal if there are missing shared libraries (like libgs.so or libpotrace.so) which frequently break dvisvgm after TeX Live or system updates.