flathub / com.visualstudio.code

https://flathub.org/apps/details/com.visualstudio.code
150 stars 69 forks source link

flatpak installed vscode's integrated terminal not having desired behaviour #44

Closed mundusnine closed 6 years ago

mundusnine commented 6 years ago

Linux distribution and version

Debian 9 strecth

Flatpak version

Flatpak 0.8.9

Description of the problem

Microsoft/vscode-cpptools#1550 The fact that the app is virtualized makes it so that you can't run : flatpak run org.godotengine.Godot or any flatpak command in the integrated terminal of vscode. You can't also use gnome-terminal as your integrated terminal in vscode because of this. This makes it also troublesome when trying to use external apps that are used by the extensions.(i.e. My haxe extensions in vscode can't find haxe in my path even though it is installed).

Haxe is available in /usr/bin/ so I guess vscode should detect it.

Steps to reproduce

Potential solution:

Adding --filesystem=/bin/ access to vscode ? Are there any reasons for not doing this ? What would be the work around.

mundusnine commented 6 years ago

Probably the real issue

Ok so I found out that the installation of Vscode considers only some apps in the /usr/bin/*.

So if you do in the integrated terminal of vscode:

which g++
which bash 
which python

It will work. But if you do:

which gnome-terminal
which haxe

It won't work saying no gnome-terminal in (/app/bin:/usr/bin:/home/jsnadeau/.var/app/com.visualstudio.code/data/node_modules/bin)

This behavior seems weird. I thought at first that it could be because haxe is a x-sharedlib but python is the same and it works.

Does the manifest determine what apps from usr/bin/ can be added ? Is there a way to tell it to use everything or just some apps.(looked in the docs and doesn't seem so)

barthalion commented 6 years ago

The main feature of Flatpak is sandboxing and there is no way to disable it. /usr and /bin you see in the integrated terminal come from Sdk, not your own system. If you pass --talk-name=org.freedesktop.Flatpak you can spawn commands on host with flatpak-spawn --host.

mundusnine commented 6 years ago

So how can vscode-extensions use outside components ? I talked about haxe but vscode can't use pylint either since it's limited to what is present in the Sdk.

Setting their path in the user settings doesn't work either.

allo- commented 6 years ago

The main feature of Flatpak is sandboxing and there is no way to disable it. /usr and /bin you see in the integrated terminal come from Sdk, not your own system. How do I install stuff into the sandboxed /usr? Is there something like

flatpak add-to-sandbox com.visualstudio.code org.gnome.gnome-terminal # add gnome terminal package to the vscode sandbox

possible?

TingPing commented 6 years ago

@allo- No, they could have conflicting files.

allo- commented 6 years ago

Is there another way to get vscode to work? Internal terminal doesn't seem to be usable for debugging and whitelisting /usr isn't visible inside the jail. At least putting an xterm inside would be helpful.

TingPing commented 6 years ago

For the terminal to run on the host requires modifications to how the terminal works.

allo- commented 6 years ago

I guess running inside the jail would be the nicer solution, but for the moment I would like anything which allows me to test vscode with gdb debugging (Compiling a sample project and then pressing F5 should work ;-)).

TingPing commented 6 years ago

Well gdb is already in the SDK, but ofc that is only useful if you compile software against the SDK.

Really IDEs just need to be designed to be sandbox friendly which I know isn't helpful now.

danielfm123 commented 5 years ago

For developing is better to use snap IDEs like visual studio or pycharm.

thiblahute commented 5 years ago

For reference, I am using fedora silverblue with toolbox and I added the following to my settings:

    "terminal.integrated.shellArgs.linux": [
        "/var/home/thiblahute/bin/my-devtools/vscode-enter"
    ],

where the vscode-enter script contains:

#!/bin/sh

flatpak-spawn --host toolbox enter

This actually works pretty well for me :-)

Ablu commented 4 years ago

This actually works pretty well for me :-)

    "terminal.integrated.shell.linux": "flatpak-spawn",
    "terminal.integrated.shellArgs.linux": [
        "--host",
        "toolbox",
        "run",
        "bash"
    ],

^ that is a bit more robust for me. But the shell spawning time is really bad...

Iolaum commented 4 years ago

@thiblahute @Ablu Where/How did you add those settings? I am getting weird behaviour in flatpak VSCode terminal as well.

Iolaum commented 4 years ago

After looking at it a little more, I think the above settings are described here.

marquesmateus93 commented 2 years ago

Just to improve your tip, @Ablu :

{
    "terminal.integrated.shell.linux": "flatpak-spawn",
    "terminal.integrated.shellArgs.linux":[
        "--host",
        "toolbox",
        "run",
        "bash"
    ],
}
UniversalSuperBox commented 2 years ago

vscode is now deprecating the terminal.integrated.shell.linux setting in exchange for terminal profiles. Here is how you can configure a flatpak escape profile:

    "terminal.integrated.profiles.linux": {
        "Flatpak Escape": {
            "path": "flatpak-spawn",
            "args": [
                "--host",
                "toolbox",
                "run",
                "bash"
            ],
        }
      },
      "terminal.integrated.defaultProfile.linux": "Flatpak Escape"
YuvanNeko commented 2 years ago

vscode is now deprecating the terminal.integrated.shell.linux setting in exchange for terminal profiles. Here is how you can configure a flatpak escape profile:

    "terminal.integrated.profiles.linux": {
        "Flatpak Escape": {
            "path": "flatpak-spawn",
            "args": [
                "--host",
                "toolbox",
                "run",
                "bash"
            ],
        }
      },
      "terminal.integrated.defaultProfile.linux": "Flatpak Escape"

It says end of the file expected.

UniversalSuperBox commented 2 years ago

It says end of the file expected.

Check your JSON syntax. You might need a comma before or after the block you've pasted into your config file.

vwalek commented 2 years ago

I use this:

    "terminal.integrated.profiles.linux": {
        "BASH": {
          "path": "/usr/bin/flatpak-spawn",
          "args": ["--host", "--env=TERM=xterm-256color", "bash"]
        },
        "ZSHELL": {
          "path": "/usr/bin/flatpak-spawn",
          "args": ["--host", "--env=TERM=xterm-256color", "zsh"]
        },
        "Flatpak": {
          "path": "/bin/bash"
        }
    },

The zshell works out of the box with themes, just colors are little of (especially yellow). I also run flatpak bash to get into the isolated env. Hope it help ;)

//update However, VSCode version 1.64 - on flatpak, has issues with default profiles. Works on 1.63.

cengiz7 commented 2 years ago

After 1 day, here is my working solution for ZSH shell on Elementary OS 6

"terminal.integrated.shell.linux": "/usr/bin/env",
"terminal.integrated.shellArgs.linux": ["flatpak-spawn", "--host", "--env=TERM=xterm-256color", "zsh"],
"terminal.integrated.fontFamily": "MesloLGS NF, Regular",
Nightfirecat commented 2 years ago

The recommendation of using terminal.integrated.defaultProfile.linux paired with a profile definition does not work for me. I've recently installed the flatpak on Debian 11, and adding the following to settings.json did nothing:

"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
    "bash": {
      "path": "/usr/bin/flatpak-spawn",
      "args": ["--host", "--env=TERM=xterm-256color", "bash"]
    },
},

Launching a terminal still brought up a sh terminal, and there were no options available when running the "Terminal: Select Default Profile" command.

The only thing which did work was adding:

"terminal.integrated.shell.linux": "/bin/bash",

I'm not satisfied with that, though, since this is deprecated. I'd like to get the more future-proof profile method working if possible.

Iolaum commented 2 years ago

For what it's worth the "solution" I m using now is to spawn the terminal and manually run the appropriate flatpak-spawn command. Not a proper fix but better than nothing.

vwalek commented 2 years ago

The recommendation of using terminal.integrated.defaultProfile.linux paired with a profile definition does not work for me. I've recently installed the flatpak on Debian 11, and adding the following to settings.json did nothing:

"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
    "bash": {
      "path": "/usr/bin/flatpak-spawn",
      "args": ["--host", "--env=TERM=xterm-256color", "bash"]
    },
},

Launching a terminal still brought up a sh terminal, and there were no options available when running the "Terminal: Select Default Profile" command.

The only thing which did work was adding:

"terminal.integrated.shell.linux": "/bin/bash",

I'm not satisfied with that, though, since this is deprecated. I'd like to get the more future-proof profile method working if possible.

What version are you running? There is issue with newer versions, 1.64+.

Nightfirecat commented 2 years ago

I'm on version 1.66.1, so I suppose that would be affected.

vwalek commented 2 years ago

I'm on version 1.66.1, so I suppose that would be affected.

Yeah, seems like the 1.66 doesn't even start the default profiles at all.

Running manually the spawn, it works.

Nightfirecat commented 2 years ago

I was experiencing #288, which was fixed in #309. I'm now able to remove the terinal.integrated.shell.linux line and use the profile definition without issue.

sigmaSd commented 1 year ago

This is what worked for me https://github.com/flathub/com.visualstudio.code/issues/315#issuecomment-1181637777

frknltrk commented 7 hours ago

I've had the same issue of some commands not recognized by integrated terminal in VSCodium (Flatpak) on Linux Mint. Try adding the below key-value pairs to your settings.json (Manage > Settings > Open Settings (JSON))

    {
        "terminal.integrated.defaultProfile.linux": "bash",
        "terminal.integrated.env.linux": {
            "PATH": "/run/host/bin:/run/host/usr/bin"
        }
    }

Path Format:

'/run/host/' + '/some/path/to/somewhere'

Paths are separated by ':'

You may want to run echo $PATH in your external (built-in) terminal to explore the PATHs set.

Reference: https://www.reddit.com/r/flatpak/comments/lm2lln/comment/gntpr80/