tmux-continuum icon indicating copy to clipboard operation
tmux-continuum copied to clipboard

New window is always added when auto restoring tmux environment

Open while0pass opened this issue 6 years ago • 16 comments

Every time I start tmux and it restores the environment, a new additional session with a blank window is added. There is no such a problem if I restore my sessions with tmux-ressurect manually.

while0pass avatar May 30 '18 11:05 while0pass

I find this annoying too. I think there should be an option to remove the session that appears when tmux is started up

dylan-chong avatar Jun 28 '18 00:06 dylan-chong

As a temporary hack, I added tmux kill-session -t 0 before the main() stop_spinner call in .tmux/plugins/tmux-resurrect/scripts/restore.sh:369, since all my sessions are named and the unwanted one is always called 0

AdrienLemaire avatar Jan 22 '20 00:01 AdrienLemaire

Hi, Here is a possible solution to this issue : pull-request https://github.com/tmux-plugins/tmux-continuum/pull/83

The problem to clean this added session at each restart is that when you are in the process of daemon creation (calling tmux-continuum), you can't kill session. So i had to externalize the call of tmux daemon in the script to have possibility to kill session after the daemon is started.

aguytech avatar Dec 08 '20 08:12 aguytech

For some reason a new window is no longer created for me now

dylan-chong avatar Dec 08 '20 20:12 dylan-chong

@dylan-chong Which OS and tmux version do you use ?

aguytech avatar Dec 08 '20 20:12 aguytech

For me: I tried few days ago with a fresh install of tmux-resurrect & tmux-continuum from github my tmux version are 3.1_c-1 Os: manjaro

Here is my problem:

$ tmux ls
0: 1 windows (created Sun Nov 29 01:04:07 2020)
$ systemctl restart --user tmux.service
$ systemctl restart --user tmux.service
$ systemctl restart --user tmux.service
$ tmux ls
0: 1 windows (created Sun Nov 29 01:14:50 2020)
1: 1 windows (created Sun Nov 29 01:14:50 2020)
2: 1 windows (created Sun Nov 29 01:14:50 2020)
3: 1 windows (created Sun Nov 29 01:14:51 2020)

Something seems to be wrong?

Here is my file .tmux.conf without binds:

# prefix key
set-option -g prefix C-q
# time allowed to repeat key following prefix key
set-option -g repeat-time 500
# set history to 5000
set-option -g history-limit 5000

# tmux-continuum
set -g @continuum-boot 'on'
set -g @continuum-restore 'on'

####  plugins

# resurect plugin
run-shell ~/.tmux/plugins/tmux-resurrect/resurrect.tmux
run-shell ~/.tmux/plugins/tmux-continuum/continuum.tmux

aguytech avatar Dec 08 '20 20:12 aguytech

@dylan-chong Which OS and tmux version do you use ?

> tmux -V
tmux 3.1c

Mac os 10.14.6

My tmux conf is here https://github.com/dylan-chong/dotfiles/commit/0c9a4840e73f9c33b1189bf8a5a9361b13874612

dylan-chong avatar Dec 08 '20 20:12 dylan-chong

Mac os 10.14.6

Ok the problem seems to come from systemd (linux)

aguytech avatar Dec 08 '20 21:12 aguytech

Nevermind. the problem is back for me :( I swear it was fine in the last few weeks

dylan-chong avatar Dec 08 '20 21:12 dylan-chong

Yeah this happens for me on MacOS.

austinbutler avatar Dec 08 '20 21:12 austinbutler

Hey guys, the original problem with session 0 being always present is solved via https://github.com/tmux-plugins/tmux-resurrect/commit/5f5f9d8fd5ff9769e5ef08d64a430ee7ab525dc7

About the new problem "session with an increasing session number appears after restart":

  • I confirm we have a bug.
  • I suspect that's a bug in tmux-resurrect, not tmux-continuum (but we can continue the discussion here).
  • I tried reproducing this yesterday, but I was unable to. I'm running tmux next-3.3.
  • Having detailed reproduction steps would be useful at this point. Please ensure you have latest tmux-resurrect and tmux-continuum installed. Please also try with latest tmux version.

bruno- avatar Dec 15 '20 13:12 bruno-

What is the current status of this bug?

I am a new user to tmux and tmux-continuum so I am confused at what I was seeing. I expected that I this plugin will being me back to my saved session when I had the following settings:

set -g @continuum-boot 'on' set -g @continuum-restore 'on'

Instead I always got a new session with a new higher session number that I have to manually get rid of. This actually creates more work than not using the feature at all.

Is this the expected behavior or is this still the bug. From a (confused) new user perspective I wanted the plugin to restore my last saved session. When I launch tmux I wanted it to bring me back to this session. When I started the computer I wanted tmux to return me to the last saved session but it doesn't do this at all. This bug report was opened almost 3 years ago... is this feature still currently broken? Are there any easy work arounds?

ioogithub avatar Feb 25 '22 23:02 ioogithub

There is one easy workaround: set @continuum-systemd-start-cmd = 'start-server'

It defaults to new-session -d, which creates the new session each time, then restores the others. I am not entirely sure why.

Note that setting this variable is not enough, you need to force regeneration of your systemd unit file - so either delete ~/.config/systemd/user/tmux.service and the script should recreate it, or just hand edit the aforementioned file manually.

UbiquitousPhoton avatar May 18 '22 16:05 UbiquitousPhoton

There is one easy workaround: set @continuum-systemd-start-cmd = 'start-server'

What does between the " " is this where you place the command you want to start or is this command complete as it is? I tried this but it did not work. When I enable this command and reload tmux I still get the default. I saw the documentation mentioned this as well but I have tried several different attempts and never got it working.

ioogithub avatar Aug 29 '22 02:08 ioogithub

the original problem with session 0 being always present is solved via tmux-plugins/tmux-resurrect@5f5f9d8

Has anyone else confirmed this change is working? I am running tmux 3.2a and tmux-restore version 4.0 (as per the CHANGELOG.mg file in my ~.tmux/plugins/tmux-resurrect/ folder) but I get a new 0 session after every restore. I have tested this extensively tonight.

I believe this 0 session is also causing other issues with restoring.

Example after a restore:

user@server:~$ tmux list-session
0: 1 windows (created Sun Aug 28 22:27:48 2022)
test: 7 windows (created Sun Aug 28 22:27:46 2022) (attached)

ioogithub avatar Aug 29 '22 02:08 ioogithub

When I installed tmux-continuum via tpm, my stored sessions were restored and I did not get any extra session. When I called tmux-continuum directly from tmux.conf with

run-shell <path to continuum.tmux>

I always ended up with my stored sessions being restored and an extra session.

I believe that the cause for that is the order of execution. In the former case, tmux would source tmux.conf, then create a new session, then tpm would invoke tmux-continuum and it would call tmux-resurrect to correctly restore my stored sessions replacing the existing session. In the latter case, tmux would source tmux.conf, calling tmux-continuum and waiting for it, then tmux-continuum would call tmux-resurrect to restore the stored sessions, and only then tmux would finish its initialization by creating a new session.

I could fix that behaviour by running continuum.tmux in the background at the bottom of tmux.conf with

run-shell -b <path to continuum.tmux>

i.e. by adding the -b flag to run-shell. Like that, tmux does not wait for continuum.tmux and instead finishes its initialization and creates a new session before tmux-continuum calls tmux-resurrect to restore the stored sessions.

kranich avatar May 19 '24 07:05 kranich