tmux fails to start in local session #7159

Closed
opened 2026-01-31 00:56:41 +00:00 by claunia · 18 comments
Owner

Originally created by @kasper93 on GitHub (Mar 26, 2020).

Environment

Windows 10.0.18363.0
f986539e3c
WT @ 31efd69149
Fully updated Cygwin as of 2020-03-26
Fully updated MSYS2 as of 2020-03-26

Steps to reproduce

  1. Run tmux

Expected behavior

tmux works

Actual behavior

tmux doesn't work

open terminal failed: not a terminal

Even more info

tmux works fine in

  • Cygwin@Mintty
  • MSYS2@Mintty
  • wsl
  • in ssh session
Originally created by @kasper93 on GitHub (Mar 26, 2020). # Environment Windows 10.0.18363.0 https://github.com/tmux/tmux/commit/f986539e3c1c8757d443ea61c9c155c36aae38d7 WT @ https://github.com/microsoft/terminal/commit/31efd69149c3b23c000c7491f98254356b1eaf34 Fully updated Cygwin as of 2020-03-26 Fully updated MSYS2 as of 2020-03-26 # Steps to reproduce 1. Run tmux # Expected behavior tmux works # Actual behavior tmux doesn't work ``` open terminal failed: not a terminal ``` ### Even more info tmux works fine in * Cygwin@Mintty * MSYS2@Mintty * wsl * in ssh session
claunia added the Needs-Tag-FixNeeds-AttentionProduct-Terminal labels 2026-01-31 00:56:42 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Mar 26, 2020):

This is almost certainly a Cygwin runtime issue, as it’s failing to detect that the windows console host is attached. MinTTY is somewhat of a red herring- it has a special handshake that it does with Cygwin to assume terminal responsibility.

How are you launching your Cygwin profile?

@DHowett-MSFT commented on GitHub (Mar 26, 2020): This is almost certainly a Cygwin runtime issue, as it’s failing to detect that the windows console host is attached. MinTTY is somewhat of a red herring- it has a special handshake that it does with Cygwin to assume terminal responsibility. How are you launching your Cygwin profile?
Author
Owner

@kasper93 commented on GitHub (Mar 26, 2020):

For Cygwin I do (it is the same with bash):

"commandline": "C:/cygwin/bin/zsh.exe --login -i",

For MSYS2 (but it is Cygwin in disguise, so probably the same issue)

"commandline": "C:/MSYS/msys2_shell.cmd -defterm -no-start",

MinTTY is somewhat of a red herring- it has a special handshake that it does with Cygwin to assume terminal responsibility.

I understand that. I report here, because it would be nice to make it work in WT. But if you tell me that it need to be fixed on Cygwin side I guess I will redirect my request to them.

I did quick test with ConEmu and it has the same issue,

Ugh, I may have fire to fast with reporting this issue. It seems to be known issue.
https://github.com/cmderdev/cmder/issues/453
https://github.com/alacritty/alacritty/issues/1687
https://github.com/zeit/hyper/issues/3608

@kasper93 commented on GitHub (Mar 26, 2020): For Cygwin I do (it is the same with bash): ``` "commandline": "C:/cygwin/bin/zsh.exe --login -i", ``` For MSYS2 (but it is Cygwin in disguise, so probably the same issue) ``` "commandline": "C:/MSYS/msys2_shell.cmd -defterm -no-start", ``` > MinTTY is somewhat of a red herring- it has a special handshake that it does with Cygwin to assume terminal responsibility. I understand that. I report here, because it would be nice to make it work in WT. But if you tell me that it need to be fixed on Cygwin side I guess I will redirect my request to them. I did quick test with ConEmu and it has the same issue, Ugh, I may have fire to fast with reporting this issue. It seems to be known issue. https://github.com/cmderdev/cmder/issues/453 https://github.com/alacritty/alacritty/issues/1687 https://github.com/zeit/hyper/issues/3608
Author
Owner

@zadjii-msft commented on GitHub (Mar 26, 2020):

Thanks for following up with all those other issues! Looks like there's a pretty broad problem across terminal emulators on Windows. Do you know if there's actually an upstream bug on cygwin that's tracking this bug? I'd love to resolve this issue as a dup of the upstream one, but I want to make sure the diligence is done ☺️

@zadjii-msft commented on GitHub (Mar 26, 2020): Thanks for following up with all those other issues! Looks like there's a pretty broad problem across terminal emulators on Windows. Do you know if there's actually an upstream bug on cygwin that's tracking this bug? I'd love to resolve this issue as a dup of the upstream one, but I want to make sure the diligence is done ☺️
Author
Owner

@kasper93 commented on GitHub (Mar 26, 2020):

I searched their ML and there seems to be no report about this specific issue. They don't have public bug tracker except mailing list. I will send them mail and see what they say.

@kasper93 commented on GitHub (Mar 26, 2020): I searched their ML and there seems to be no report about this specific issue. They don't have public bug tracker except mailing list. I will send them mail and see what they say.
Author
Owner

@DHowett-MSFT commented on GitHub (Mar 26, 2020):

Since this looks pretty widespread, I'm gonna close out our copy of it. I'd definitely watch their mailing list, though, if I had a link to an ML archive for this report 😄

@DHowett-MSFT commented on GitHub (Mar 26, 2020): Since this looks pretty widespread, I'm gonna close out our copy of it. I'd definitely watch their mailing list, though, if I had a link to an ML archive for this report :smile:
Author
Owner

@kasper93 commented on GitHub (May 14, 2020):

After all I forgot to link here upstream report: https://sourceware.org/pipermail/cygwin/2020-March/244192.html Unfortunately, it went nowhere.

Sometimes you need to fix things by yourself... maybe when I feel the need for tmux again.

EDIT:

And explanation why this actually happens. https://cygwin.com/pipermail/cygwin/2020-May/244878.html

@kasper93 commented on GitHub (May 14, 2020): After all I forgot to link here upstream report: https://sourceware.org/pipermail/cygwin/2020-March/244192.html Unfortunately, it went nowhere. Sometimes you need to fix things by yourself... maybe when I feel the need for tmux again. EDIT: And explanation why this actually happens. https://cygwin.com/pipermail/cygwin/2020-May/244878.html
Author
Owner

@sfzhi commented on GitHub (Oct 13, 2021):

For those who wish to use Windows Terminal + Cygwin + tmux, there is a workaround. It's not a very elegant one, but it appears to work.

Use the following command line in the Windows Terminal profile to start Cygwin:
C:\Cygwin\bin\sh.exe -lc "exec dtach -c /tmp/dtach-shell-$$ -Ez /bin/bash -i"

For this to work, dtach must be available in Cygwin. Unfortunately, Cygwin does not provide a binary package. Fortunately, dtach is very small and easy to build from source.

@sfzhi commented on GitHub (Oct 13, 2021): For those who wish to use Windows Terminal + Cygwin + tmux, there is a workaround. It's not a very elegant one, but it appears to work. Use the following command line in the Windows Terminal profile to start Cygwin: `C:\Cygwin\bin\sh.exe -lc "exec dtach -c /tmp/dtach-shell-$$ -Ez /bin/bash -i"` For this to work, [dtach](http://dtach.sourceforge.net/) must be available in Cygwin. Unfortunately, Cygwin does not provide a binary package. Fortunately, dtach is very small and easy to build from source.
Author
Owner

@mrjohannchang commented on GitHub (Jan 10, 2022):

Update

  1. Tested both ConEmu and Cmder, they do NOT have this issue. CC @kasper93
  2. Found 2 workarounds for Windows Terminal + MSYS2. CC @sfzhi
    1. Run tmux with this command: script -c tmux /dev/null. Source. CC @csdvrx
    2. windows-alt-sshd-msys2 CC: @rkitover

Related info

  1. Neovim doesn't work in Windows tmux nor MinTTY. https://github.com/neovim/neovim/issues/6751
@mrjohannchang commented on GitHub (Jan 10, 2022): **Update** 1. Tested both [ConEmu ](https://github.com/Maximus5/ConEmu) and [Cmder](https://github.com/cmderdev/cmder), they do **NOT** have this issue. CC @kasper93 2. Found 2 workarounds for Windows Terminal + MSYS2. CC @sfzhi 1. Run tmux with this command: `script -c tmux /dev/null`. [Source](https://news.ycombinator.com/item?id=28759834). CC @csdvrx 2. [windows-alt-sshd-msys2](https://github.com/rkitover/windows-alt-sshd-msys2) CC: @rkitover **Related info** 1. Neovim doesn't work in Windows tmux nor MinTTY. https://github.com/neovim/neovim/issues/6751
Author
Owner

@PrashanthaTP commented on GitHub (Jan 14, 2022):

Thank you so much @kasper93 @changyuheng @sfzhi for the research done and workarounds.
(I will always be thankful to windows terminal team).

TLDR : script.exe actually comes with util-linux package (msys2)

it may be already known, but commenting here just to save time for someone like me who is
searching for script.


I was wandering around the internet for months to get tmux
working in windows terminal (without wsl)

For anyone who wants to get windows terminal+ git bash+tmux without installing full package of cygwin or msys, we can do so by getting just tmux and script binary from msys packages (check once in the msys package page to verify if you already have its dependencies) and putting the so got files in respective folders of C:/Program Files/Git.

References :

script.exe : packages.msys2.org/package/util-linux
scrip.exe is actually in util-linux package : https://github.com/msys2/MINGW-packages/issues/4497

@PrashanthaTP commented on GitHub (Jan 14, 2022): Thank you so much @kasper93 @changyuheng @sfzhi for the research done and workarounds. (I will always be thankful to windows terminal team). TLDR : `script.exe` actually comes with `util-linux` package (msys2) it may be already known, but commenting here just to save time for someone like me who is searching for `script`. --- I was wandering around the internet for months to get [`tmux`](https://github.com/tmux/tmux) working in windows terminal (without wsl) For anyone who wants to get `windows terminal`+ `git bash`+`tmux` without installing full package of cygwin or msys, we can do so by getting just `tmux` and `script` binary from msys packages (check once in the msys package page to verify if you already have its dependencies) and putting the so got files in respective folders of `C:/Program Files/Git`. References : `script.exe` : [packages.msys2.org/package/util-linux](https://packages.msys2.org/package/util-linux?repo=msys&variant=x86_64) `scrip.exe is actually in util-linux package` : https://github.com/msys2/MINGW-packages/issues/4497
Author
Owner

@Cici-Li-Sky commented on GitHub (Jan 14, 2022):

改为中文看不懂

@Cici-Li-Sky commented on GitHub (Jan 14, 2022): 改为中文看不懂
Author
Owner

@ducklin5 commented on GitHub (Apr 2, 2022):

If you are using the script screen or dtach workaround:

You'll need to export a couple of environmental variables in your .bashrc or .zshrc files to get your cool fonts working:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
@ducklin5 commented on GitHub (Apr 2, 2022): If you are using the `script` `screen` or `dtach` workaround: You'll need to export a couple of environmental variables in your `.bashrc` or `.zshrc` files to get your cool fonts working: ```bash export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 ```
Author
Owner

@rkitover commented on GitHub (Apr 2, 2022):

Is anyone following up on fixing this in tmux itself?

@rkitover commented on GitHub (Apr 2, 2022): Is anyone following up on fixing this in `tmux` itself?
Author
Owner

@dgasaway commented on GitHub (Apr 20, 2023):

1. Tested both [ConEmu ](https://github.com/Maximus5/ConEmu) and [Cmder](https://github.com/cmderdev/cmder), they do **NOT** have this issue. CC @kasper93

@changyuheng The statement that you tested ConEmu is pretty vague. I can say that if I try to run cygwin tmux from cmd.exe or cygwin bash in ConEmu, I get the same error as Windows Terminal. If I host a mintty session in ConEmu, I can run tmux, but then I'm running a different terminal emulator that is known to work.

@dgasaway commented on GitHub (Apr 20, 2023): > 1. Tested both [ConEmu ](https://github.com/Maximus5/ConEmu) and [Cmder](https://github.com/cmderdev/cmder), they do **NOT** have this issue. CC @kasper93 @changyuheng The statement that you tested ConEmu is pretty vague. I can say that if I try to run cygwin tmux from cmd.exe or cygwin bash in ConEmu, I get the same error as Windows Terminal. If I host a mintty session in ConEmu, I can run tmux, but then I'm running a different terminal emulator that is known to work.
Author
Owner

@sventek-s commented on GitHub (Nov 21, 2023):

Thank you so much @kasper93 @changyuheng @sfzhi for the research done and workarounds. (I will always be thankful to windows terminal team).

TLDR : script.exe actually comes with util-linux package (msys2)

it may be already known, but commenting here just to save time for someone like me who is searching for script.

I was wandering around the internet for months to get tmux working in windows terminal (without wsl)

For anyone who wants to get windows terminal+ git bash+tmux without installing full package of cygwin or msys, we can do so by getting just tmux and script binary from msys packages (check once in the msys package page to verify if you already have its dependencies) and putting the so got files in respective folders of C:/Program Files/Git.

References :

script.exe : packages.msys2.org/package/util-linux scrip.exe is actually in util-linux package : msys2/MINGW-packages#4497

How exactly do you get it to work. I copied the binaries but still I get the open terminal failed: not a terminal on Git Bash

After you copy the binaries from C:\msys64\usr\bin to C:\Program Files\Git\usr\bin I used this alias stollen from netheril96

# placed it in ~/.bash_profile for both GIT BASH and MYSYS2
tmux() {
  # execute tmux with script
  TMUX="command tmux ${@}"
  SHELL=/usr/bin/bash script -qO /dev/null -c "eval $TMUX"
}
@sventek-s commented on GitHub (Nov 21, 2023): > Thank you so much @kasper93 @changyuheng @sfzhi for the research done and workarounds. (I will always be thankful to windows terminal team). > > TLDR : `script.exe` actually comes with `util-linux` package (msys2) > > it may be already known, but commenting here just to save time for someone like me who is searching for `script`. > > I was wandering around the internet for months to get [`tmux`](https://github.com/tmux/tmux) working in windows terminal (without wsl) > > For anyone who wants to get `windows terminal`+ `git bash`+`tmux` without installing full package of cygwin or msys, we can do so by getting just `tmux` and `script` binary from msys packages (check once in the msys package page to verify if you already have its dependencies) and putting the so got files in respective folders of `C:/Program Files/Git`. > > References : > > `script.exe` : [packages.msys2.org/package/util-linux](https://packages.msys2.org/package/util-linux?repo=msys&variant=x86_64) `scrip.exe is actually in util-linux package` : [msys2/MINGW-packages#4497](https://github.com/msys2/MINGW-packages/issues/4497) ~~How exactly do you get it to work. I copied the binaries but still I get the `open terminal failed: not a terminal` on Git Bash~~ After you copy the binaries from `C:\msys64\usr\bin` to `C:\Program Files\Git\usr\bin` I used this alias stollen from [netheril96](https://github.com/alacritty/alacritty/issues/1687#issuecomment-1282482768) ```sh # placed it in ~/.bash_profile for both GIT BASH and MYSYS2 tmux() { # execute tmux with script TMUX="command tmux ${@}" SHELL=/usr/bin/bash script -qO /dev/null -c "eval $TMUX" } ```
Author
Owner

@martin-braun commented on GitHub (Jan 25, 2024):

The thing is still not fixed, wow.

On top of that, .tmux.conf doesn't work at all, and things need to load using the script method. Example: https://github.com/srouquette/msys2/blob/master/home/Syl/tmux.conf.sh

@martin-braun commented on GitHub (Jan 25, 2024): The thing is still not fixed, wow. On top of that, `.tmux.conf` doesn't work at all, and things need to load using the script method. Example: https://github.com/srouquette/msys2/blob/master/home/Syl/tmux.conf.sh
Author
Owner

@ms-jpq commented on GitHub (Apr 4, 2024):

Running tmux under script seems to be unacceptably slow, especially over SSH.

@ms-jpq commented on GitHub (Apr 4, 2024): Running `tmux` under `script` seems to be unacceptably slow, especially over SSH.
Author
Owner

@lonelam commented on GitHub (Apr 24, 2024):

Hi I just inspected the problem, I checked tmux source code and it seems that the key problem is tmux's tty detection failed on Windows Terminal, while the detection on mintty successed:
https://github.com/tmux/tmux/blob/master/tty.c#L107

So maybe the problem is, on windows, the cmd.exe or terminal.exe indeed not create a tty file to let the tmux to operate, and they are actually not a real terminal according to the following explanation:
https://unix.stackexchange.com/questions/4126/what-is-the-exact-difference-between-a-terminal-a-shell-a-tty-and-a-con

Maybe modifying msys2 could change this behavior? Or just not to use windows for development.

@lonelam commented on GitHub (Apr 24, 2024): Hi I just inspected the problem, I checked tmux source code and it seems that the key problem is tmux's tty detection failed on Windows Terminal, while the detection on mintty successed: https://github.com/tmux/tmux/blob/master/tty.c#L107 So maybe the problem is, on windows, the cmd.exe or terminal.exe indeed not create a tty file to let the tmux to operate, and they are actually not a real terminal according to the following explanation: https://unix.stackexchange.com/questions/4126/what-is-the-exact-difference-between-a-terminal-a-shell-a-tty-and-a-con Maybe modifying msys2 could change this behavior? Or just not to use windows for development.
Author
Owner

@rkitover commented on GitHub (Jul 20, 2024):

Hi, can anyone interested in this problem please try a tmux branch I'm working on, the police is not letting me test it.

It is the cygwin-support branch in my tmux fork here:

https://github.com/rkitover/tmux/tree/cygwin-support

To build do this in an MSYS shell on MSYS2:

git clone git@github.com:rkitover/tmux
cd tmux
git checkout cygwin-support
pacman -S --noconfirm gcc make bison autoconf automake libevent-devel ncurses-devel pkgconf
sh autogen.sh
./configure --prefix=/usr/local
make -j8

, this will create a tmux.exe in this directory.

@rkitover commented on GitHub (Jul 20, 2024): Hi, can anyone interested in this problem please try a tmux branch I'm working on, the police is not letting me test it. It is the `cygwin-support` branch in my tmux fork here: https://github.com/rkitover/tmux/tree/cygwin-support To build do this in an MSYS shell on MSYS2: ```bash git clone git@github.com:rkitover/tmux cd tmux git checkout cygwin-support pacman -S --noconfirm gcc make bison autoconf automake libevent-devel ncurses-devel pkgconf sh autogen.sh ./configure --prefix=/usr/local make -j8 ``` , this will create a `tmux.exe` in this directory.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#7159