Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mundusnine opened this issue Aug 25, 2018 · 29 comments
Closed

Comments

@mundusnine
Copy link

mundusnine commented Aug 25, 2018

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

  • Install vscode with flatpak
  • use the integrated terminal of vscode(try with sh/bash) and call flatpak list

Potential solution:

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

@mundusnine
Copy link
Author

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
Copy link
Member

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
Copy link
Author

mundusnine commented Aug 25, 2018

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-
Copy link

allo- commented Sep 14, 2018

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
Copy link
Member

@allo- No, they could have conflicting files.

@allo-
Copy link

allo- commented Sep 14, 2018

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
Copy link
Member

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

@allo-
Copy link

allo- commented Sep 14, 2018

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
Copy link
Member

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
Copy link

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

@thiblahute
Copy link

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
Copy link

Ablu commented Dec 25, 2019

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
Copy link

Iolaum commented Sep 6, 2020

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

@Iolaum
Copy link

Iolaum commented Sep 6, 2020

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

@marquesmateus93
Copy link

Just to improve your tip, @Ablu :

  • File > Preferences > Configuration
  • In search bar, type "terminal"
  • Look up in results for "Terminal › Integrated › Automation Shell: Linux"
  • Click in "Edit settings.json"
  • Then replace the .json file content to:
{
    "terminal.integrated.shell.linux": "flatpak-spawn",
    "terminal.integrated.shellArgs.linux":[
        "--host",
        "toolbox",
        "run",
        "bash"
    ],
}

@UniversalSuperBox
Copy link

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
Copy link

YuvanNeko commented Dec 9, 2021

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
Copy link

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
Copy link
Contributor

vwalek commented Feb 20, 2022

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
Copy link

cengiz7 commented Mar 7, 2022

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
Copy link

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
Copy link

Iolaum commented Apr 22, 2022

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
Copy link
Contributor

vwalek commented Apr 22, 2022

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
Copy link

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

@vwalek
Copy link
Contributor

vwalek commented Apr 22, 2022

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
Copy link

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
Copy link

sigmaSd commented Oct 14, 2023

This is what worked for me #315 (comment)

@frknltrk
Copy link

frknltrk commented Oct 18, 2024

EDIT (21/01/2025)
Better solution: #44 (comment)

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/

@andrew-ma
Copy link

REFERENCE: https://github.com/flathub/com.vscodium.codium/blob/master/README.md#host-shell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests