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

Catch and prompt action for corrupted resurrect files

Open metasoarous opened this issue 4 years ago • 7 comments

I just had a problem where all of a sudden running tmux was immediately exiting with [exited]. After a bit of digging around I realized that the ~/.tmux/resurrect/last file was pointing to an empty resurrect file! The fix was easy enough, but it took me quite a while to resolve this and was rather handicapped at the terminal until I did.

I'm not sure why the resurrect file didn't save properly, and it may not even be possible to fix whatever the issue was. But I'm wondering if it would be possible to catch this edge case and present a prompt asking if the user would like to reload a different resurrect (perhaps the most recent non-empty) session. Even a warning that the resurrect file was empty and can't be loaded before exiting (with some tips on how to fix) would have saved me a ton of time. Is this something you'd consider?

Thanks for your time, and the awesome plugin!

metasoarous avatar Aug 28 '21 16:08 metasoarous

ksnip_20210905-143317

I have exactly the same problem. This issue is especially problematic if you automatically start tmux with your shell because it will prevent you from using your terminal. I think there should be a check that makes tmux-resurrect fail gracefully, e. g. something as simple as displaying a message like "Error: Could not load resurrect file. Starting new session instead ...".

I'm not sure why there are corrupted / zero-byte resurrect files in the first place, though. I think the underlying issue should be fixed as well.

ret2src avatar Sep 05 '21 12:09 ret2src

Thanks for chiming in @ret2src. Glad I'm not the only one here. (misery loves company?)

I'd be pretty happy with that solution. I can't really think of a situation where I'd want an earlier version of the session (I probably wouldn't even notice). And if someone did, catching the warning would give them enough info to mess around with the last pointer until they get what they want.

I definitely agree that fixing the underlying problem would be nice as well (if possible). In my case, I think there had been a hard reset or battery failure somewhere in the interim, so maybe there were some hanging file handles that didn't get closed out properly?

Thanks again

metasoarous avatar Sep 06 '21 15:09 metasoarous

I got this problem today, when a colleague has restarted a server without noticing others, and now I cannot start tmux (it exits immediately).

dmitry-kabanov avatar Aug 25 '22 08:08 dmitry-kabanov

@dmitry-kabanov Delete the corrupted file and you should be good

ret2src avatar Aug 25 '22 08:08 ret2src

Encountered the same issue today, thanks @metasoarous, you are a life saver.

me2r036 avatar Aug 31 '23 06:08 me2r036

rtmux() {
	cd ~/.local/share/tmux/resurrect/ || exit # Your save path
	find . | sort | tail -n 1 | xargs rm
	find . -printf "%f\n" | sort | tail -n 1 | xargs -I {} ln -sf {} last
	cd - || exit
}

This issue occurs periodically,I solved it with a simple shell command.

Myxhf avatar Apr 17 '24 05:04 Myxhf