flathub / dev.lapce.lapce

https://flathub.org/apps/details/dev.lapce.lapce
8 stars 2 forks source link

Can't use plugins where binaries are used from PATH #32

Open VarLad opened 1 year ago

VarLad commented 1 year ago

There are some plugins which use the binary from system PATH. Any idea how I can use those plugins with the Flatpak? Works with the released binaries

sebastian-de commented 1 year ago

I guess this is a sandbox issue again. Can you be a bit more specific on which plugin you want to use and where the needed binaries are?

You can try something like flatpak override --user dev.lapce.lapce --env=PATH=/app/bin:/usr/bin:/home/user/.cargo/bin But I guess this won't work if the binaries are in /usr/bin since the sandbox has its own /usr/bin directory.

nalsai commented 1 year ago

I'm having the same issue: I want to use the C# (omnisharp) plugin. It needs dotnet and omnisharp installed. I just downloaded omnisharp, put it in my home folder and specified its path in the plugin settings. For dotnet there is an extension (https://github.com/flathub/org.freedesktop.Sdk.Extension.dotnet7). To be able to use it . /usr/lib/sdk/dotnet7/enable.sh would have to be run before Lapce starts.

The VS Code Flatpak uses a startup script to enable sdk extensions (https://github.com/flathub/com.visualstudio.code/blob/master/code.sh). Maybe Lapce could add something similar?

The html lsp extension needs vscode-langservers-extracted, which I can install on my system using npm and access from the flatpak at /run/host/usr/local/lib/node_modules/vscode-langservers-extracted/, but it needs nodejs to run. nodejs could be installed as a flatpak extension too, like dotnet.

nalsai commented 1 year ago

I managed to get vscode-html-language-server and therefore the html lsp extension to work: Note: I'm using Fedora 37, on your system the paths may be different.

Install node and vscode-langservers-extracted on host.

sudo dnf install npm
sudo npm i -g vscode-langservers-extracted

In the lapce settings for the html plugin set the path to html-language-server to /run/host/usr/local/lib/node_modules/vscode-langservers-extracted/bin/vscode-html-language-server.

flatpak override --user dev.lapce.lapce --env=PATH=/app/bin:/usr/bin:/run/host/usr/bin:/run/host/usr/local/bin Allows access to the following: /run/host/usr/bin -> /usr/bin (contains node) /run/host/usr/local/bin -> /usr/local/bin (contains node modules)

It shouldn't cause any major problems, as flatpak native binaries are preferred, because they are first in path.

flatpak override --user dev.lapce.lapce --env=LD_LIBRARY_PATH=/run/host/usr/local/lib:/home/nalsai/Apps/lib Allows access to the following: /run/host/usr/local/lib -> /usr/local/lib (contains node module libs) /home/nalsai/Apps/lib libnode and libuv are required to run node, so I copied them to a separate folder:

mkdir -p /home/nalsai/Apps/lib
cp /usr/lib64/libnode.so.108 /home/nalsai/Apps/lib/
cp -r /usr/lib64/libuv* /home/nalsai/Apps/lib/

Using LD_LIBRARY_PATH=...:/run/host/usr/lib64 does not work, as it contains a lot of different libs (basically everything) from the host system, which breaks the whole flatpak if you try to add it.

I wouldn't recommend this, as it's pretty hacky and could easily break stuff. But at least it shouldn't break anything permanently and is easy to revert by just removing the environment variable overrides from the flatpak again.

Ideally, lapce extensions should include or automatically download all required files and things like dotnet or node could be installed as flatpak extensions, like I described above.

ell1e commented 10 months ago

Maybe at least the PATH change could be done inside the flatpak permanently? Because then any LSPs that are self-contained (and don't rely on external libraries) would already work.