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

Save failure corrupts resurrect storage

Open ain opened this issue 10 years ago • 22 comments

I'm constantly having

    '/Users/ain/.tmux/plugins/tmux-resurrect/scripts/save.sh' returned 1  

which ends up in 0-length txt file at .tmux/resurrect, every time.

I think the save script should safeguard the behaviour and not dump a file on failure.

ain avatar Oct 29 '15 14:10 ain

Thanks for reporting this. Any idea why the save script fails?

bruno- avatar Nov 25 '15 12:11 bruno-

I'm encountering this issue fairly regularly as well. What can I do to find the cause of it? The only behaviours I can think of are long lasting sessions and restoring my laptop from sleep states. No hard metrics though

rperryng avatar Mar 08 '16 23:03 rperryng

Yes, it looks like a core problem of those /private… temporary folders getting lost and so the session is corrupt.

ain avatar Mar 09 '16 08:03 ain

+1 I am also getting this issue regularly

effektz avatar Mar 15 '16 16:03 effektz

Well I get it as well. I have tried to run the script by hand doing ~/.tmux/plugins/tmux-resurrect/scripts/save.sh

and the error is connecting to /private/var/folders/d0/xbg08_x12lddw3dkht5w462c0000gn/T/tmux-501/default (No such file or directory)

foice avatar Mar 16 '16 21:03 foice

Is there at least a manual workaround for saving sessions when this happens?

foice avatar Mar 16 '16 21:03 foice

Yes.

  1. cd ~/.tmux/resurrect
  2. rm <all 0 byte txt files>
  3. unlink last
  4. ln -s <last txt file> last

ain avatar Mar 16 '16 21:03 ain

thanks for your input. I did that but the session file I get is empty and the error is still the same. Any idea?

foice avatar Mar 17 '16 10:03 foice

You didn't do your process correctly. The last symlink must still link to a 0-byte text file that was created by the save malfunction.

ain avatar Mar 17 '16 10:03 ain

I have followed your step, 1 by one 1, is that what you doubt I did correctly?

Just to make sure, I have removed all zero size files, and unlinked "last", now, what should I do? if I have to link a valid non-zero-size file, then it's what I did ... and it still gives me the error.

I have also tried to stop at step 3 and do the save command, but still I get the same. Hope I made clearer what I did ...

foice avatar Mar 17 '16 10:03 foice

Step 4 is crucial. You need to link the last non 0 byte file (the one that is not corrupt) to last in your resurrect folder.

ain avatar Mar 17 '16 12:03 ain

ok, then is what I am doing. -rw-r--r-- 1 roberto staff - 3.6K Nov 23 17:27 tmux_resurrect_2015-11-23T17:27:14.txt lrwxr-xr-x 1 roberto staff - 38B Mar 17 14:08 last -> tmux_resurrect_2015-11-23T17:27:14.txt

but still the save script does not work. Would you mind explaining the logic of this fix? it seems the proble is related to connecting to /private/var/folders/d0/xbg08_x12lddw3dkht5w462c0000gn/T/tmux-501/default (No such file or directory)

I do not see how you 4-step solution will fix that.

foice avatar Mar 17 '16 13:03 foice

It's not about the save, it's the environment issue. I'm having the same problem not only on tmux, but also Vim, for an unknown reason so far, but the way to recover in those circumstances is to shut down tmux (:kill-server) and restart it.

ain avatar Mar 17 '16 13:03 ain

interesting. so is this in alternative to the 4-step above or is after that?

and, if I may, what would be the restart command to be given after the :kill-server, I'd like to try, but want to do it right.

Thanks for helping

foice avatar Mar 17 '16 13:03 foice

:kill-server will kill the whole tmux. Once those 4 steps have been successfully completed, you can start tmux up again.

ain avatar Mar 17 '16 15:03 ain

I see, so this is not "a manual workaround for saving sessions when this happens", it's just quit tmux and restart, loosing my current session pane list, or am I mistaken?

foice avatar Mar 17 '16 17:03 foice

Yes, correct. I haven't managed to save it if it's corrupt already. It's a good practice to make sure to save your tmux env as you change it.

This ticket here is chiefly to discuss saving a 0 byte txt file that should not happen. If save fails, rollback to last known stable should happen automatically, to avoid manually going through the aforementioned 4 steps.

ain avatar Mar 18 '16 15:03 ain

Yes, correct. I haven't managed to save it if it's corrupt already.

... which was my original question ...

foice avatar Mar 20 '16 09:03 foice

Any news on this? I get this all the time and it drives me nuts.

maxcr avatar Oct 16 '17 18:10 maxcr

Hey peeps, I've never experienced this issue. I see there was a proposal how to deal with the situation after this has happened, but did anyone discover what's causing this in the first place?

bruno- avatar Oct 19 '17 10:10 bruno-

Well I get it as well. I have tried to run the script by hand doing ~/.tmux/plugins/tmux-resurrect/scripts/save.sh

and the error is connecting to /private/var/folders/d0/xbg08_x12lddw3dkht5w462c0000gn/T/tmux-501/default (No such file or directory)

I run into this today. The save.sh script failed with multiple error connecting to /tmp/tmux-1000/default (No such file or directory). Same output from tmux ls.

The socket file indeed was not there, I don't know how or why it disappeared :)

Is there at least a manual workaround for saving sessions when this happens?

SOLUTION

I solved the problem by running pkill -USR1 tmux. It recreated the socket file and then the save.sh script and other tmux commands worked as expected.

Sending the SIGUSR1 signal to regenerate the socket is documented in man tmux.

rhcarvalho avatar Jul 10 '19 13:07 rhcarvalho

Ran into this problem too and unfortunately pkill -USR1 tmux did not create the required socket file and solve the problem.

Error message on my side is:

error connecting to /private/tmp/tmux-501/default (No such file or directory)

repeated a bunch of times probably due to retry.

louy2 avatar May 08 '22 02:05 louy2