Auto tmux on startup fails with error "Not a terminal" #11765

Closed
opened 2026-01-31 02:56:43 +00:00 by claunia · 3 comments
Owner

Originally created by @jediahkatz on GitHub (Dec 11, 2020).

Environment

Windows build number: 10.0.19041.630
Windows Terminal version (if applicable): 1.4.3243.0

Any other software?

I am running `zsh` 5.8 (with `oh-my-zsh`) in WSL 2.

Steps to reproduce

  1. Add the following to ~/.zshrc:
# Always work in a tmux session if tmux is installed
# Based on https://github.com/chrishunt/dot-files/blob/master/.zshrc
if which tmux 2>&1 >/dev/null; then
  if [ $TERM != "screen-256color" ] && [ $TERM != "screen" ]; then
    tmux new-session -A -s main; exit
  fi
fi
  1. Set Windows Terminal default to WSL and set default shell to zsh.
  2. Try repeatedly opening Windows Terminal (if it opens successfully, then do CTRL+D and try again).

Expected behavior

Windows Terminal should always open normally with zsh inside tmux.

Actual behavior

Windows Terminal frequently fails on startup with:

open terminal failed: not a terminal

[process exited with code 1]
Originally created by @jediahkatz on GitHub (Dec 11, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: 10.0.19041.630 Windows Terminal version (if applicable): 1.4.3243.0 Any other software? I am running `zsh` 5.8 (with `oh-my-zsh`) in WSL 2. ``` # Steps to reproduce 1. Add the following to `~/.zshrc`: ``` # Always work in a tmux session if tmux is installed # Based on https://github.com/chrishunt/dot-files/blob/master/.zshrc if which tmux 2>&1 >/dev/null; then if [ $TERM != "screen-256color" ] && [ $TERM != "screen" ]; then tmux new-session -A -s main; exit fi fi ``` 2. Set Windows Terminal default to WSL and set default shell to `zsh`. 3. Try repeatedly opening Windows Terminal (if it opens successfully, then do CTRL+D and try again). # Expected behavior Windows Terminal should always open normally with `zsh` inside `tmux`. # Actual behavior Windows Terminal frequently fails on startup with: ``` open terminal failed: not a terminal [process exited with code 1] ```
claunia added the Needs-TriageResolution-ExternalNeeds-Tag-Fix labels 2026-01-31 02:56:43 +00:00
Author
Owner

@skyline75489 commented on GitHub (Dec 11, 2020):

Does this only happen with zsh? How often does this fail if you try it repeatedly

@skyline75489 commented on GitHub (Dec 11, 2020): Does this only happen with zsh? How often does this fail if you try it repeatedly
Author
Owner

@jediahkatz commented on GitHub (Dec 11, 2020):

I was unable to reproduce this with vanilla bash by putting the same code in my .bashrc. I would say it fails about 1/3 of the time... you need to actually make sure the tmux session closes (rather than just detaching) in order to reproduce this exact error, although sometimes if you just detach you can still get a different error.

Right now I am using a temporary workaround that automatically opens a new Windows Terminal window when tmux fails, basically "trying again" -- so far, it seems like tmux never fails the second time around (in the new window). Also, if you modify the .zshrc to not exit after tmux fails, then you can just run tmux new-session -A -s main manually in the terminal and it also seems to never fail.

@jediahkatz commented on GitHub (Dec 11, 2020): I was unable to reproduce this with vanilla bash by putting the same code in my `.bashrc`. I would say it fails about 1/3 of the time... you need to actually make sure the tmux session closes (rather than just detaching) in order to reproduce this exact error, although sometimes if you just detach you can still get a different error. Right now I am using a temporary workaround that automatically opens a new Windows Terminal window when tmux fails, basically "trying again" -- so far, it seems like tmux never fails the second time around (in the new window). Also, if you modify the `.zshrc` to not `exit` after tmux fails, then you can just run `tmux new-session -A -s main` manually in the terminal and it also seems to never fail.
Author
Owner

@DHowett commented on GitHub (Dec 14, 2020):

Thanks for the report! As far as I can tell, this is either a WSL or tmux issue. The terminal presents the same interface to all client applications, on all startups -- that of an interactive Windows Console console session. This would be the same as running conhost wsl repeatedly -- the window might just disappear too quickly to be seen.

This would probably be a good issue to file on the WSL repo.

@DHowett commented on GitHub (Dec 14, 2020): Thanks for the report! As far as I can tell, this is either a WSL or tmux issue. The terminal presents the same interface to all client applications, on all startups -- that of an interactive Windows Console console session. This would be the same as running `conhost wsl` repeatedly -- the window might just disappear too quickly to be seen. This would probably be a good issue to file [on the WSL repo](https://github.com/microsoft/wsl).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#11765