Open JonasLoos opened 4 years ago
This is how Flatpak is expected to work in a sense. It's sandboxed, so it doesn't get access to your system :smile:
Nonetheless, I think it would probably make the editor more useful to allow this stuff. We already give it access to all files on your system, since it doesn't use the secure file open portal to only get access to what you choose to edit, so it's not like it would be less secure than it already is.
I am not sure how to do this in a permanent way. Your host system's programs should be visible from within the sandbox in the path /run/host/usr/bin
and adding this to the path should be enough to run Python scripts such as pandoc. For binaries such as javac that probably use libraries from the host system as well, it won't be enough, so we have to add the host libraries to the library search path too. I managed to get a binary to work by starting the editor from the command line with the following incantation:
flatpak run --env=PATH=/app/bin:/usr/bin:/run/host/usr/bin --env=LD_LIBRARY_PATH=/run/host/usr/lib/x86_64-linux-gnu com.sublimetext.three
Try that and see if it works for you, or you may need to adjust the paths according to how they are set up on your system. But like I said, I'm not sure how to do this in a way that will work for everyone.
I thought of another thing that might work. Try prefixing the commands in the build systems with flatpak-spawn --host
, e.g. replace javac
with flatpak-spawn --host javac
. This would require launching the app from the command line with an extra argument, --talk-name=org.freedesktop.Flatpak
to give it permission to run commands on the host system.
Try either/both of these and let me know if they work for you.
Thanks for the answer, here are my results:
Running
flatpak run --env=PATH=/app/bin:/usr/bin:/run/host/usr/bin --env=LD_LIBRARY_PATH=/run/host/usr/lib/x86_64-linux-gnu com.sublimetext.three
gives the error
/app/extra/opt/sublime_text/sublime_text: error while loading shared libraries: libpcre.so.3: cannot open shared object file: No such file or directory
Opening sublime with only flatpak run --env=PATH=/app/bin:/usr/bin:/run/host/usr/bin com.sublimetext.three
works, but pandoc doesn't seem to be able to access some libraries (but at least pandoc is found):
pandoc: error while loading shared libraries: libpcre.so.3: cannot open shared object file: No such file or directory
javac
is still not found
To me it looks like I should use another LD_LIBRARY_PATH
but I don't know which one 😅, using Ubuntu 19.10.
running flatpak run --talk-name=org.freedesktop.Flatpak com.sublimetext.three
and changing the build system to use flatpak-spawn --host
was successful 😁
Both javac and my pandoc script work.
lets see if it's convenient enough to replace the snap sublime-text version permanently
I copied /var/lib/flatpak/exports/share/applications/com.sublimetext.three.desktop
to /home/jonas/.local/share/applications
and added --talk-name=org.freedesktop.Flatpak
to the Exec
lines. So I don't have to start it from the cmdline anymore
Thanks for testing. For the env
method you can find where javac
is located by typing which javac
at your terminal and add the path where it is located to the PATH
string, separated from the other paths with a :
character. Pretty much the same for libpcre, you can use something like find /usr -name libpcre.so.3
(or probably apt-file search libpcre.so.3
on your Ubuntu system) and add that path to the LD_LIBRARY_PATH
string.
However, this does probably indicate that it's not possible to edit the path and/or library path in a way that works for everyone.
We can at least include the flatpak spawn permission in this app's manifest by default so that everyone can do this.
I'm curious, are you editing Sublime's built-in build system definitions or ones that you got from Package Control plugins? Which ones? We might be able to already put overrides into place for the built-in ones but people would still be on their own for Package Control ones, and how to fix it wouldn't be very discoverable, so that's unfortunate.
I'm using self created build systems, just created from Tools > Build System > New Build System...
. I left the built-in ones unchanged until now.
For example I'm using an own build system calling a shell script to convert .md
files to .pdf
, or one which uses python3 instead of the default python (2).
When creating a new build system a very simple template is shown. Maybe it would be possible to change that to initially include flatpak-spawn --host
.
build-in and custom build systems can't find the given commands, e.g. java:
This also happens in scripts which are called in build systems:
adding a PATH option or a prefix to a command (e.g. using /usr/bin/pandoc) doesn't solve the problem.
This problem doesn't occur in the snap version of sublime text. I noticed a similar problem in atom installed using flatpak.