flathub / dev.zed.Zed

https://flathub.org/apps/details/dev.zed.Zed
9 stars 4 forks source link

"No such file or directory" #3

Open rudolf-enum opened 1 month ago

rudolf-enum commented 1 month ago

Hello, I'm having trouble running this on Alpine Linux -- though I assume that the choice of distro shouldn't matter too much since it's flatpak.

Zed doesn't even start, flatpak run dev.zed.Zed immediately fails to launch the binary.

$ flatpak run dev.zed.Zed
Portal call failed: Failed to start command: Failed to execute child process “/var/lib/flatpak/app/dev.zed.Zed/x86_64/stable/29feaf6558a8c888be0fba1f474731bb7775cee82c1dfd126e724122c643e3e7/files/bin/zed” (No such file or directory)

The file is there, but I can't run it directly (outside of flatpak) because Alpine has musl instead of glibc and the Linux release of Zed is dynamically linked to glibc.

$ /var/lib/flatpak/app/dev.zed.Zed/x86_64/stable/29feaf6558a8c888be0fba1f474731bb7775cee82c1dfd126e724122c643e3e7/files/bin/zed
exec: Failed to execute process '/var/lib/flatpak/app/dev.zed.Zed/x86_64/stable/29feaf6558a8c888be0fba1f474731bb7775cee82c1dfd126e724122c643e3e7/files/bin/zed': The file exists and is executable. Check the interpreter or linker?

There is a seemingly relevant open issue in Flatpak itself where the OS is NixOS, which tends to share with Alpine these kinds of issues.

Since I don't have issues with any other Flatpak package, could it be that the issue is with dev.zed.Zed? Thank you.

rudolf-enum commented 1 month ago

Just found this note on the Zed website which could explain this.

Screenshot_20240729_173254

Source

ShobuPrime commented 1 month ago

Another thing to consider regarding the sandbox from @someone13574's comment:

There is a environment variable, ZED_FLATPAK_NO_ESCAPE, that disables the sandbox escape if set to anything, causing the app to be launched from inside the sandbox.

Let us know if staying within the sandbox works for you

rudolf-enum commented 1 month ago

That worked, thanks @ShobuPrime . Though as expected, the things listed in the comment simply don't work -- e.g. the terminal, which seems to be some sort of a Flatpak /bin/sh shell.

$ flatpak override dev.zed.Zed --env=ZED_FLATPAK_NO_ESCAPE=true --user

$ flatpak run dev.zed.Zed
vixalien commented 1 month ago

I was having the same issue and passing ZED_FLATPAK_NO_ESCAPE=1 as an env var fixed it.

doing an ldd on zed, it turns out that it requires glibc, which I don't have on my alpine system. I think escaping the flatpak sandbox misses the entire point of flatpak, and maybe this flag can be added as default in this project.

Erven2016 commented 1 month ago

image

I also had this issue in NixOS, but your method solved my problem.

That worked, thanks @ShobuPrime . Though as expected, the things listed in the comment simply don't work -- e.g. the terminal, which seems to be some sort of a Flatpak /bin/sh shell.

$ flatpak override dev.zed.Zed --env=ZED_FLATPAK_NO_ESCAPE=true --user

$ flatpak run dev.zed.Zed
rudolf-enum commented 1 month ago

Come to think of it, wouldn't it be possible to specifically re-include the org.freedesktop.Sdk-bundled libs so that musl libc users can run it without the ESCAPE? I'm assuming that's the only thing preventing it from running.

I tried the following without success, but that could be just my lack of understanding of how LD_LIBRARY_PATH works.

flatpak override --user dev.zed.Zed --env=LD_LIBRARY_PATH="/var/lib/flatpak/runtime/org.freedesktop.Sdk/x86_64/23.08/be4a045f86be2b8a7a592bab299c7dd41c174eba94ab804
8401b1fa01c9eb86a/files/lib/x86_64-linux-gnu/"
rudolf-enum commented 4 weeks ago

Oh, nevermind, the LD_LIBRARY_PATH can be modified directly inside Zed too (it's defined together with the NO_ESCAPE var), however no matter what I set it to, the problem is still the same.

$ flatpak run --verbose dev.zed.Zed
[redacted]
F: Running 'bwrap --args 37 -- zed'
Portal call failed: Failed to start command: Failed to execute child process “/var/lib/flatpak/app/dev.zed.Zed/x86_64/stable/dc4752dc5761f9d27856381519f381170580c99c6bc020aad980cea8efe18378/files/bin/zed” (No such file or directory)

It seems that the issue is not with the bundled libs.

vixalien commented 3 weeks ago

So I think the current best approach if you want (or need) to use Zed without the sandbox escape is to enable the ZED_FLATPAK_NO_ESCAPE=1 variable, and then add the following to user settings:

{
  "terminal": {
    "shell": {
      "with_arguments": {
        "program": "flatpak-spawn",
        "args": ["--host", "--env=TERM=xterm-256color", "bash"]
      }
    }
  }

This will enable the terminal to launch as if it was on the host.

This was adapted from VSCode. It would be better if host-spawn was bundled together with the app though.

someone13574 commented 3 weeks ago

It would be better if host-spawn was bundled together with the app though.

That’s what I was doing in some earlier prototypes of flatpak support, but the Zed developers were against having a third party program as a critical part. Not sure if it not being the primary method changes anything.

vixalien commented 3 weeks ago

but the Zed developers were against having a third party program as a critical part.

Sure, but adding a sandbox escape is a worse idea tbh.