Why, after a Ubuntu 14.04 software update, does have exec tmux
in my .bashrc lead to not being able to log in (though previously it worked fine for years) and how to fix ?
Investigation:
I recently did a Ubuntu 14.04 update and then couldn't even log in to the system at all. Only the fact that I once created another account on this machine (so do that now yourself! have the account have little to no .bashrc stuff) made fixing it relatively easy. Having previously made an extra account that has admin saved me. Also the fact that I can log into that account and then when doing
su other_account_name
- Which initially still fails as it tries to use .bashrc -
I can actually do
su other_account_name -s /bin/sh
instead to just use the basic sh shell and avoid bash.
Then I can edit the bashrc and fix what's wrong, save the file and all is restored. Phew!
Investigation complete. Back to the question...
So, after all this, I finally tracked down the issue to the fact that having exec tmux
in my .bashrc using
[ -z "$TMUX" ] && command -v tmux > /dev/null && TERM=xterm-256color && tmux
was messing up logging in initially.
However, if I'm already logged in, that allows new windows (that have tmux activated) to be created without a problem.
How to fix and be able to use tmux and have my .bashrc still work for initial login?
Notes:
- I can do
exec tmux
after logging in and it gets activated and I can use it ok. - I tried changing
exec tmux
totmux
in the line in.bashrc
and it 'half' helped - I get an 'invalid' message popup* when I log in to the account - but tmux has been invoked and is usable. - I checked and I seem to have a current version - 1.9a - of tmux
The popup that I get when I changed my
./bashrc
to havetmux
instead ofexec tmux
contains:Error foud when loading /home/durrant/.profile:\n\n open terminal failure: not a terminal\n\n As a result the session will not be configured correctly.
You should fix the problem as soon as possible.I've also tried having
tmux
on its own line in my .bashrc
file and also having
[ -z "$TMUX" ] && tmux
but got the same errors
.bashrc
is read every time you open a shell, second, the TERM variable inside tmux has to be set to screen*, and third, your overall approach is just wrong: spawn a tmux session on login and then open shells in that, not the other way around...