66

I used home-brew to setup tmux on a mac. When trying to run tmux I keep on getting this error

open terminal failed: missing or unsuitable terminal: xterm-256color

any suggestions?

eugen
  • 8,916
  • 11
  • 57
  • 65
user3256740
  • 669
  • 1
  • 6
  • 4

7 Answers7

55

Your system doesn't have xterm-256color. You could:

  • Set TERM to something other than xterm-256color outside tmux (try just plain export TERM=xterm).

  • See if there is a package containing xterm-256color, perhaps a later version of ncurses or terminfo.

  • Install it manually from another system with something like:

    infocmp -x xterm-256color > out
    

    Then transfer the "out" file to your Mac and try:

    tic out
    
Stefan
  • 1,697
  • 15
  • 31
bob
  • 551
  • 3
  • 2
42

This happened to me during a system upgrade. Unfortunately I did not see a way besides restarting: tmux kill-server and then run tmux.

Tatsh
  • 2,780
  • 1
  • 20
  • 23
  • 4
    Arch users: This is the answer you are looking for. – Leon Adler Mar 11 '18 at 16:41
  • 10
    Not just Arch. Probably generically Linux. And you don't have to kill your servers ungracefully. In the shell, before you try to reattach, set TERM to some other value, such as `export TERM=xterm` or `export TERM=screen`, then you can reattach. At that point, you can end all your programs and shells gracefully. Once all the tmux sessions for the same user are ended, you can restart tmux with the new version. – Pistos Mar 27 '18 at 02:33
  • 2
    Not even generically Linux. I had to do this after updating MacPorts while tmux was running. Fortunately I saw this before trying more radical solutions. – Jim Stewart May 15 '18 at 01:46
  • 1
    I didn't want to kill tmux, because then I would have no way to interact with the upgrade. `export TERM=xterm` was the solution. – isaaclw May 27 '20 at 18:22
25

you can just type export TERM=xterm in console when you see this error, or put export TERM=xterm in the file ~/.bash_profile and source ~/.bash_profile. then you may never get this error again.
This works fine on my debian.

Shawn Wang
  • 761
  • 8
  • 9
  • This also worked on Windows. On [tmux with git bash](https://gist.github.com/DeanPDX/acff533cff0cfbda2761d1e62e8cb1a7). – Akaisteph7 Jul 25 '22 at 16:49
19

TL;DL

sudo ln -sf /usr/share/terminfo/x/xterm-color /usr/share/terminfo/x/xterm-256color

Details

Maybe the file /usr/share/terminfo/x/xterm-256color is corrupted. It may be fixed upon (system/package) upgrade / reinstall.

Meanwhile you can use other terminfo entry. You can get the available options by ls /usr/share/terminfo/x.

I am having the same problem and using xterm-16color meanwhile.

To set terminfo, you can type reset in the terminal, then select the terminfo:

username:~$ cd /usr/share/terminfo/x
username:x$ ls
x10term          xnuppc+200x64    xterm-24         xterm+pcfkeys
x1700            xnuppc-200x64-m  xterm-256color   xterm-pcolor
x1700-lm         xnuppc-200x75    xterm+256color   xterm-r5
...
username:x$ reset
reset: unknown terminal type xterm-256color
Terminal type? xterm-16color

=== Edit 2018 Feb 20 ===

You should config the term in many places if you want to make it permanent, for example, .vimrc, .tmux.config, .Xresources, e.t.c.

I still have issue when using terminator -x 'tmux attach -t music; exec bash' So I'm using a quick hack as below:

cd /usr/share/terminfo/x
sudo mv xterm-256color xterm-256color.bk
sudo ln -sf /usr/share/terminfo/x/xterm-color /usr/share/terminfo/x/xterm-256color
Beeno Tung
  • 1,058
  • 10
  • 17
10

When I removed some sessions/windows this error went away for me. Apparently I had too many TTY's open.

You can kill sessions/windows from outside tmux with these commands:

tmux kill-session -t <session-name>
tmux kill-window -t <session-name>:<window-name>
gitaarik
  • 42,736
  • 12
  • 98
  • 105
2

I am also having the same issue.

export TERM=xterm
tmux kill-server

This helps solve the problem: https://www.peterdavehello.org/2019/11/tmux-open-terminal-failed-missing-or-unsuitable-terminal-xterm-256color/

GPrathap
  • 7,336
  • 7
  • 65
  • 83
0

In my case Xterm was absent. (But I had the same error on Ubuntu)

Andrey
  • 1,528
  • 14
  • 12