flathub / com.visualstudio.code.oss

https://flathub.org/apps/details/com.visualstudio.code.oss
GNU Affero General Public License v3.0
47 stars 12 forks source link

System integration, default shell, and host commands #45

Closed BobyMCbobs closed 4 years ago

BobyMCbobs commented 5 years ago

It is possible to run host commands when inside the Flatpak container, however the user must run flatpak-spawn --host bash.

Currently, vscode-oss just uses the standard user's shell contained in the Flatpak container.

To add some integration to the vscode-oss, it would be nice to have the default shell launch flatpak-spawn --env=COLORTERM=truecolor --env=TERM=xterm-256color --host /bin/sh -c "\$(getent passwd \$USER | cut -d: -f7)".

Some extensions also rely on host binary for such things as linting code (e.g PHP), etc...; This would also enable such functionality which simply isn't possible in it's current form.

As an example, an app which does this currently is GNOME Builder.

TingPing commented 5 years ago

This is largely a discussion to have upstream (or in some extension) not a packaging issue.

dAnjou commented 4 years ago

Hi @TingPing, can you elaborate why this is an upstream issue? What @BobyMCbobs said sounds like a packaging issue.

For example in my setup I can't access java for some reason even though I clearly have it installed: Screenshot from 2019-12-01 15-19-28

BobyMCbobs commented 4 years ago

For example in my setup I can't access java for some reason even though I clearly have it installed

@dAnjou, this is because Flatpak has a contained environment for each app. Apps aren't able to access all of the programs on your host. You may be able to access it in your /run/host/usr/bin/java, otherwise try the command which I said about (flatpak-spawn --env=COLORTERM=truecolor --env=TERM=xterm-256color --host /bin/sh -c "\$(getent passwd \$USER | cut -d: -f7)").

TingPing commented 4 years ago

Flatpak is a sandbox, it can't be not-sandboxed.

If you want to execute commands they either run on the host (flatpak-spawn --host) or they get packaged into the sandbox.

There is nothing that this package can do. The application should be designed to understand running commands in different contexts and support flatpak directly.

springbov commented 4 years ago

I'm posting what I've found here as a note for any other unwary traveler asking such questions.

What wasn't immediately clear to me when reading this, is that it is possible to run an un-sandboxed shell inside of the flatpak build of vscode-oss.

I found that editing my settings.json file I could change my default shell to run the commands mentioned by BobyMCbobs and TingPing to run an unsandboxed shell.

It's hacky and I don't trust it. If you are concerned more about having an OSS build and less about sandboxing I'd personally look at vscodium instead.

{
    "terminal.integrated.shell.linux": "flatpak-spawn",
    "terminal.integrated.shellArgs.linux": [
        "--env=COLORTERM=truecolor",
        "--env=TERM=xterm-256color",
        "--host",
        "/bin/sh",
        "-c",
        "$(getent passwd $USER | cut -d: -f7)"
    ]
}