Weird PATH value when running Flatpak application

Hello,

I wanted to use LaTeX on my desktop. In my laptop this already works:

  • I installed texlive from brew
  • I installed TexStudio flatpak

I just tried to do the same on my desktop and somehow it does not work. When I try to compile the document in TexStudio I get:

Process started: flatpak-spawn --host xelatex -synctex=1 -interaction=nonstopmode "myfile".tex

Portal call failed: Failed to start command: Failed to execute child process “xelatex” (No such file or directory)
Process exited with error(s)

I am not sure what to do here. If I open a terminal and try xelatex, it works:

user@host ~> xelatex --version
XeTeX 3.141592653-2.6-0.999996 (TeX Live 2024/Homebrew)
kpathsea version 6.4.0
Copyright 2024 SIL International, Jonathan Kew and Khaled Hosny.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the XeTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the XeTeX source.
Primary author of XeTeX: Jonathan Kew.
Compiled with ICU version 74.2; using 74.2
Compiled with zlib version 1.3.1; using 1.3.1
Compiled with FreeType2 version 2.13.2; using 2.13.3
Compiled with Graphite2 version 1.3.14; using 1.3.14
Compiled with HarfBuzz version 9.0.0; using 9.0.0
Compiled with libpng version 1.6.43; using 1.6.43
Compiled with pplib version v2.2
Compiled with fontconfig version 2.15.0; using 2.15.0

user@host ~> which xelatex
/home/linuxbrew/.linuxbrew/bin/xelatex

Any ideas why running the host command works on one and fails on the other? I don’t actually recall doing anything special to get this working on my laptop…

I have a clue: by using “Help → Check LaTeX installation” I got a system report file which contains:

PATH=/home/linuxbrew/.linuxbrew/opt/openjdk@17/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin

Notice how the first path component is wrong. How can this happen? On a regular terminal I get:

user@host ~> echo $PATH
/home/linuxbrew/.linuxbrew/bin /home/linuxbrew/.linuxbrew/sbin /home/linuxbrew/.linuxbrew/opt/openjdk@17/bin /usr/local/bin /usr/local/sbin /usr/bin /usr/sbin

Clearly the PATH breaks when running the flatpak, but how/why? Where is this set?

EDIT: On my laptop where this actually works, somehow there is no mention of linuxbrew in the same report. Instead I get:

PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin

Somehow this is not a problem there…

After a lot of fiddling I have figured this out. Posting the outcome in the hopes that nobody else wastes as much time as I did on this.

There are two issues here:

  1. The path issue
  2. The latex binary issue

Regarding (1) it turned out that I somehow configured the path to a specific version of openjdk. I don’t recall when/how but this was stored in .config/fish/fish_variables. Removing it did not make any difference.

Ironically before I found about the above file, I was assuming this is something Homebrew does and unable to find the source I ended up removing it altogether (ujust remove-brew). When that did not help I kept searching and found it was simply fish shell configuration… So much fun…

Regarding (2) - this was a red herring! The laptop was working because I had this flatpak installed in addition to the application:

> flatpak list | grep -i texlive

TeX Live Sdk extension	org.freedesktop.Sdk.Extension.texlive	20210325	23.08	system

So the LaTeX installed with brew played no role. I ended up removing it from both laptop and desktop, opting for the flatpak instead.

I guess that it would work with Homebrew as well, but I’d need to find configuration locations to update the path to these utilities, and fiddle with Flatseal to add permissions, which I did not want to bother with, so I opted for the extra flatpak instead…