terminal: tmux fails to start in local session

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

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (4 by maintainers)

Most upvoted comments

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

改为中文看不懂

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.

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

Is anyone following up on fixing this in tmux itself?

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"
}

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

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

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

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.