flathub / com.google.AndroidStudio

https://flathub.org/apps/details/com.google.AndroidStudio
37 stars 24 forks source link

Inability to launch terminal using flatpak-spawn inside Android Studio #231

Closed Fs00 closed 1 month ago

Fs00 commented 1 month ago

Since the update to AS 2024.1, setting flatpak-spawn --host bash as the default terminal in IDE settings causes the Terminal tab to close immediately upon opening it. By reverting the default terminal to /bin/sh and running the aforementioned command, I get the error Portal call failed: org.freedesktop.DBus.Error.ServiceUnknown. According to this Reddit post, it seems that --talk-name=org.freedesktop.Flatpak is required for flatpak-spawn to work but was removed in #222. Can it be brought back?

xanscale commented 1 month ago

why you need flatpak-spawn --host bash inside Android Studio?

Due to security reasons, actual recommendation are to use spawn only if strictly required

Fs00 commented 1 month ago

I've been using flatpak-spawn --host to be able to run all tools installed on my machine in the IDE terminal, since /usr/bin is not shared with the flatpak. However, I've realized that --filesystem=host mounts host /usr/bin under /run/host/usr/bin inside the flatpak. So, if you could add the latter folder to the flatpak's PATH env, it should be possible to run all installed tools in the IDE terminal without resorting to flatpak-spawn.

xanscale commented 1 month ago

yes, but i'm also thinking to switch --filesystem=host to --filesystem=home.

flatpak app are intended to run application in a sandbox, with limited interaction with host system.

why not just open external terminal ?

PS which external tools are you using during programming android app ? the best option is to install it as flatpak extension

Fs00 commented 1 month ago

why not just open external terminal ?

Well, for convenience 😅 Why should I have to open it in an external window if I can have it right in the IDE?

which external tools are you using during programming android app ?

One example is tig (which unfortunately doesn't work with flatpak-spawn yet), but there is also vim for doing quick file edits right in the terminal (e.g. when editing commit messages during a git rebase). In any case, I don't see why the integrated terminal shouldn't have access to the same environment as outside the IDE.

flatpak app are intended to run application in a sandbox, with limited interaction with host system.

Honestly I don't think it makes much sense trying to aggressively sandbox an IDE, which runs with almost full access to the environment by design. Doing so will eventually lead to a worse UX/DX imo.

xanscale commented 1 month ago

Honestly I don't think it makes much sense trying to aggressively sandbox an IDE, which runs with almost full access to the environment by design. Doing so will eventually lead to a worse UX/DX imo.

I agree with this sentense when i think on "Normal" IDE which make program that run on same OS, like IntelliJ or VSC. Instead Android studio make app that run on external device or in emulator with no interaction with host OS. also all the tools like java, gradle, ndk or c compiler are embeded inside android studio package or SDK. there is no standard situation which AS uses tools from the host OS. (also git are included in flatpak bundle)

so in this case i'm no agree with "full access to the environment by design"

Furthermore, this approach improves compatibility with exotic operating systems such as Chrome OS or others

xanscale commented 1 month ago

Android Studio IDE can be associated with Arduino IDE, and they use same logic https://github.com/flathub/cc.arduino.IDE2/blob/master/cc.arduino.IDE2.json

if a relevant use case will not be shown about flatpak-spawn or filesystem=host i will close this issue in a days and move to filesystem=home

xanscale commented 1 month ago

@Fs00 anyway flatpak platform used in Android Studio has his own nano that can be used for git merge