You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling flatpak-spawn --host bash from inside a flatpak, it cannot work properly:
sh-4.4$ flatpak-spawn --host --env=LANG=C bash
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
The final use case is to try to set the default terminal in flatpak'd VSCode to flatpak-spawn --host toolbox enter... and, of course, that it works.
I have this problem and I am not willing to install yet another dependency, in this case toolbox, as it pulls other packages that I'd rather not have installed.
It should be the desired way, however the problem seems to be the missing env variables, even those defined in terminal.integrated.env.linux setting. It makes TERM=dumb and makes fish unusable.
@yajo, it seems it does not work from within vscode (which totally makes sense). It does work perfectly from inside a shell. I have no idea what terminal vscode emulates. If bash works when called directly, vscode does set TERM for the calling process. If so, you might use something like bash -c 'exec flatpak-spawn --host --env TERM="$TERM" ...' This will set the environment variable.
A rather ugly but usable workaround if you need something immediately could
be to run a private (not exposed to the public network) ssh server on your
host system, then drop a tiny, statically linked ssh client like dropbear
in some directory your Flatpak can access and use it to open a terminal on
the host. (I've been meaning to play with integrating this with VS Code's
ssh support automatically for some time but haven't really gotten a chance.)
A rather ugly but usable workaround if you need something immediately could be to run a private (not exposed to the public network) ssh server on your host system, then drop a tiny, statically linked ssh client like dropbear in some directory your Flatpak can access and use it to open a terminal on the host.
The problem with this approach is the loss of $PWD unless you do some more trickery to cd to the project folder.
For the specific case of Visual Studio Code, another ugly but usable workaround is to modify local files via ssh to localhost. Which maybe is not that ugly and would let you sandbox the flatpak even more.
I wonder what Tilix is doing differently. It seems to have access from flatpak to the host shell without flatpak-spawn. I just installed it from the Gnome software (thorugh flatpak fedora repo) and it seems to be working (mostly) fine.
It has some issue now with the toolbox command and the UI sometimes crashes on it's own though.
The Tilix Flatpak has always had some memory corruption / double free issues, likely tied somehow to the D-Bus calls it makes. I tried looking into it a long time ago but couldn't resolve it, which is why it was never published to Flathub.
Coming across this I figured I might want to mention what the underlying issue is, because I didn't see it mentioned here.
Years ago when doing the initial version of GNOME Builder which flatpak's everything, I had to change how PTY's were created. You need to O_NOCTTY for your PTY when going across the boundary. Otherwise, the child process with the FD's mapped as stdin/out/err will become the controlling terminal for that PTY.
Why this likely works with something like toolbox is simply because podman, underneath, is creating a sub-PTY for you (just like tmux would).
Activity
yajo commentedon Dec 9, 2019
Yikes, not sure how I managed to do this, but I fixed the issue in vscode with these settings, and they allocate a tty:
ranisalt commentedon Apr 8, 2020
I have this problem and I am not willing to install yet another dependency, in this case
toolbox, as it pulls other packages that I'd rather not have installed.ibotty commentedon Apr 29, 2020
I use
That works beautifully if TERM is set correctly in the first place.
yajo commentedon Apr 30, 2020
You cannot use that @ibotty.
If you configure vscode as this:
Then inside the terminal:
No luck...
yajo commentedon Apr 30, 2020
I have tried this and it opens a shell indeed:
It should be the desired way, however the problem seems to be the missing env variables, even those defined in
terminal.integrated.env.linuxsetting. It makesTERM=dumband makes fish unusable.Possibly due to containers/toolbox#29.
ibotty commentedon Apr 30, 2020
@yajo, it seems it does not work from within vscode (which totally makes sense). It does work perfectly from inside a shell. I have no idea what terminal vscode emulates. If bash works when called directly, vscode does set TERM for the calling process. If so, you might use something like
bash -c 'exec flatpak-spawn --host --env TERM="$TERM" ...'This will set the environment variable.ibotty commentedon Apr 30, 2020
And I am pretty sure it's unrelated to containers/toolbox#29. Because flatpak-spawn does not inherit TERM even without toolbox in sight.
yajo commentedon May 11, 2020
Yes, indeed the problem seems to be inside
flatpak-spawnitself. It's impossible for it to allocate a TTy. There should be an option for this for us to be able to workaround flathub/com.visualstudio.code#39, flathub/com.visualstudio.code.oss#5 and similar.refi64 commentedon May 12, 2020
nyx-lyb3ra commentedon May 23, 2020
I think this is a pretty good solution
Thinking that
flatpak-spawnjust needs a way to simply expose already setted env vars, likedockerorpodmanyajo commentedon May 25, 2020
OOooooOoh that works!
rh-y0n1 commentedon Jan 17, 2021
I'm using zsh as my shell and this worked for me on GoLand and WebStorm
/usr/bin/env -- flatpak-spawn --host --env=TERM=xterm-256color zshranisalt commentedon Jan 17, 2021
The problem with this approach is the loss of
$PWDunless you do some more trickery to cd to the project folder.bonzini commentedon May 11, 2021
For the specific case of Visual Studio Code, another ugly but usable workaround is to modify local files via ssh to localhost. Which maybe is not that ugly and would let you sandbox the flatpak even more.
vwalek commentedon Jun 16, 2021
Hey, thx, work as it should. I see that the vscode changed the way to integrate the shell, so use this config. Worked for me.
vteivans commentedon Feb 15, 2022
I wonder what Tilix is doing differently. It seems to have access from flatpak to the host shell without
flatpak-spawn. I just installed it from the Gnome software (thorugh flatpak fedora repo) and it seems to be working (mostly) fine.It has some issue now with the
toolboxcommand and the UI sometimes crashes on it's own though.https://github.com/gnunn1/tilix
refi64 commentedon Feb 15, 2022
Tilix uses the same D-Bus APIs that flatpak-spawn uses, it just calls them directly.
The Tilix Flatpak has always had some memory corruption / double free issues, likely tied somehow to the D-Bus calls it makes. I tried looking into it a long time ago but couldn't resolve it, which is why it was never published to Flathub.
1player commentedon Jul 26, 2022
FWIW, I have an alternative implementation of
flatpak-spawn --hostthat fixes this issue and a few others: https://github.com/1player/host-spawnAlacritty: Disable set_controlling_terminal()
chergert commentedon Nov 16, 2023
Coming across this I figured I might want to mention what the underlying issue is, because I didn't see it mentioned here.
Years ago when doing the initial version of GNOME Builder which flatpak's everything, I had to change how PTY's were created. You need to O_NOCTTY for your PTY when going across the boundary. Otherwise, the child process with the FD's mapped as stdin/out/err will become the controlling terminal for that PTY.
Why this likely works with something like toolbox is simply because podman, underneath, is creating a sub-PTY for you (just like tmux would).