tmux exits with [exited] on mac os x

90

23

I just installed tmux (a terminal multiplexer) with homebrew. When I try to run it, it always exits with [exited] Nothing shows up.

When I try to run tmux list-session I get an error:

failed to connect to server: Connection refused

I tried running tmux start-server, but again nothing happens.

What can I do?

Stevens

Posted 2012-03-05T13:50:31.947

Reputation: 1 003

2start using the -v option to increase verbosity – Florenz Kley – 2012-03-05T17:03:14.750

3Check your default-command and default-shell options. If tmux is having trouble running your default command (or shell) it will respond like you are describing. For further investigation, you can use do something like tmux new /bin/zsh to explicitly start with (e.g.) /bin/zsh instead of relying on default-command or default-shell. – Chris Johnsen – 2012-03-06T07:18:09.280

3tmux new /bin/zsh worked for me. Thank you. – Stevens – 2012-03-10T15:13:26.010

Er, my suggestion was meant as a diagnostic step, not a final workaround. There is probably something buggy about your default-shell or default-command setting. – Chris Johnsen – 2012-03-15T11:58:55.257

I recently found (for the first time) that if 1) .tmux.conf exists but has syntax errors or 2) .tmux.conf is a symbolic link that links to nothing, tmux will not open. It might be good to try at first with the default configuration file so first mv $HOME/.tmux.conf $HOME/.tmux.conf.backup and see if tmux starts. @ChrisJohnsen is right, your solution simply means that there is a bug afoot. – scicalculator – 2012-04-03T05:16:38.297

I'm having this same problem. Chris, what exactly do you mean when you say there's something wrong with default-shell or default-command? I removed my tmux.conf file altogether and I'm still getting the error. – Adam Albrecht – 2012-05-15T00:39:51.610

@AdamAlbrecht: I just came across your comment (start your comment with @username to notify a user that is participating in the comment thread). If you are using the default values of default-shell and default-command, then you should check the value of your SHELL environment variable. tmux will attempt to start an instance of your SHELL when you do not give it a command (and default-command is empty, like it is by default). Maybe something (shell initialization file?) is setting your SHELL environment variable to a pathname that does not exist, is inaccessible, or not executable. – Chris Johnsen – 2012-07-29T02:24:48.427

Answers

182

I had this same problem. It was caused by having set-option -g default-command "reattach-to-user-namespace -l zsh" in my .tmux.conf without having reattach-to-user-namespace installed.

The fix was to install "reattach-to-user-namespace" via Homebrew (brew install reattach-to-user-namespace)

robenkleene

Posted 2012-03-05T13:50:31.947

Reputation: 1 946

@DaMainBoss reattach-to-user-namespace is for tmux only. If you're on ubuntu just comment out that line from your .tmux.conf file – pho79 – 2015-02-22T03:41:04.103

Four years later and this saved me from tearing my hair out. Thanks! – Subfuzion – 2016-03-25T01:40:36.750

This wasn't the answer for me, but it lead me to the solution. My default-shell and default-command were still searching for a shell I recently deleted. Changing them to a default system shell /bin/ksh resolved this for me. – Jason Robinson – 2016-08-20T22:03:24.483

Duh. Yes. And this will probably happen every time I set up a new computer. :o – adampasz – 2017-01-01T23:04:28.333

2great thx! Exactly what was missing on my system to make it work! – DannyRe – 2012-09-04T23:24:51.280

1+1 Thanks a ton! I had exactly the same issue. Do you know any way to set options conditionally so it won't fail on a system that doesn't have reattach-to-user-namespace installed? – Patrick Oscity – 2013-05-08T08:16:45.347

2

@padde See this solution.

– jrhorn424 – 2013-10-10T22:16:38.500

Any idea how to achieve this in Ubuntu? Tried looking for a way to download reattach-to-user-namespace but my efforts were futile. – DaMainBoss – 2013-11-23T05:32:11.437

6

Do make sure that the default-shell option only contains the executable path and does not contain options.

In /etc/tmux.conf or ~/.tmux.conf

set-option -g default-shell "/bin/bash"
set-option -g default-command "bash -l"
set-option -g default-path $HOME
set-option -g default-terminal "screen-256color"

AskApache

Posted 2012-03-05T13:50:31.947

Reputation: 181

This answer led me to the real reason, I had just uninstalled tcsh, and my default shell and default command were still set to it. Changing it to /bin/ksh, or a default installed shell of your choice, fixed it for me. – Jason Robinson – 2016-08-20T22:02:02.347

3

In my situation I had been fiddling with a number of dotfiles so expected things to be amiss. My fix happened to be shutting down tmux with killall tmux. After this I was able to spin up properly.

IntelXDesign

Posted 2012-03-05T13:50:31.947

Reputation: 31

1this worked for me. thanks! – Brian Zhou – 2019-12-01T20:13:53.623

Worked for me as well – user353255 – 2020-01-06T20:05:57.397

0

If you're using a script to wrap reattach-to-user-namespace, as outlined by jimeh, don't forget to make the script executable with chmod +x ~/bin/login-shell.

jrhorn424

Posted 2012-03-05T13:50:31.947

Reputation: 240