tl;dr MaTeX 1.7.0 and later do not have this issue. Restarting Mathematica after upgrading will fix the problem.
After receiving the troubleshooting notebook from OP in e-mail, I believe this is what happened:
The problem encountered by the OP only affects MaTeX versions earlier than 1.7.0. The OP probably had such an old version. After upgrading the paclet to 1.7.4, the OP immediately tried to re-load MaTeX with Needs
instead of Get
, without restarting Mathematica. Needs
however does not re-load an already loaded package. The package was updated only on the disk, but not in-memory, thus the issue persisted.
Using Get
, or just quitting the kernel, fixes it.
I have updated the instruction to suggest using Get
instead of Needs
. Hopefully, others won't fall in the same trap.
What exactly fails in MaTeX on Linux systems prior to version 1.7.0?
MaTeX uses RunProcess
to call Ghostscript and pdflatex. Both depend on zlib. Mathematica ships an older version of zlib on Linux, and its startup script sets LD_LIBRARY_PATH
to point to Mathematica's own library directory where this zlib is located. This means that not only Mathematica, but also any other program launched by Mathematica will try to use this old zlib. However, programs shipped with recent Linux distributions require a newer zlib, and will fail when dynamically linking against Mathematica's copy.
This is what happens:
In[]:= RunProcess[{"/usr/bin/gs", "--version"}]
Out[]= <|"ExitCode" -> 1, "StandardOutput" -> "",
"StandardError" ->
"/usr/bin/gs: /opt/mathematica/SystemFiles/Libraries/Linux-x86-64/libz.so.1: \
version `ZLIB_1.2.9' not found (required by /usr/lib/x86_64-linux-gnu/libpng16.so.16)"|>
The workaround is to temporarily clear LD_LIBRARY_PATH
before running these programs. This is best achieved with the ProcessEnvironment
option of RunProcess
: preserve everything in the environment (GetEnvironment
), except LD_LIBRARY_PATH
.
Unlike SetEnvironment
, this method is safe. SetEnvironment
would affect all programs launched by Mathematica, including some of its own components.