tmux-resurrect: Error when restoring pane content

When I restore the session, an error message appears at the top of all the panes which says a file or directory could not be found.

This is what I have in .tmux.conf:

set -g @resurrect-strategy-vim 'session'  # save vim sessions (may require the tpope/vim-obsession plugin)
set -g @resurrect-strategy-nvim 'session'  # save neovim sessions (may require the tpope/vim-obsession plugin)
set -g @resurrect-capture-pane-contents 'on'  # save pane contents
set -g @continuum-restore 'on'  # restore session on tmux start
set -g @continuum-save-interval '5'  # save session every 5 minutes (default is 15)

Screenshot

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 8
  • Comments: 37 (5 by maintainers)

Commits related to this issue

Most upvoted comments

@Starefossen @ariesdevil Since the developer, @bruno-, is not responding to this bug anymore, the only solution I’ve found is to just stay on 7a8d90a. You can do that via:

$ cd ~/.tmux/plugins/tmux-resurrect && git checkout 7a8d90a27d2005792415b7a6c30ae2afd6d5838d

I am really perplexed as to why this bug hasn’t been fixed yet. There is a clear point of regression and there has been more than ample time to determine the issue. This bug has been open for about a year and a half two years now, so I am really confused as to the radio silence that this issue has received.

For some reasons (which are unknown to me), postponing restore/pane_contents clean-up after calling restore_active_pane_for_each_window (scripts/restore.sh:392) fixed the issue for me. That is:

diff --git a/scripts/restore.sh b/scripts/restore.sh
index 47907bc..835e42c 100755
--- a/scripts/restore.sh
+++ b/scripts/restore.sh
@@ -270,9 +270,6 @@ restore_all_panes() {
                        restore_pane "$line"
                fi
        done < $(last_resurrect_file)
-       if is_restoring_pane_contents; then
-               rm "$(pane_contents_dir "restore")"/*
-       fi
 }

 handle_session_0() {
@@ -375,6 +372,12 @@ restore_active_and_alternate_sessions() {
        done < $(last_resurrect_file)
 }

+cleanup_restored_pane_contents() {
+       if is_restoring_pane_contents; then
+               rm "$(pane_contents_dir "restore")"/*
+       fi
+}
+
 main() {
        if supported_tmux_version_ok && check_saved_session_exists; then
                start_spinner "Restoring..." "Tmux restore complete!"
@@ -394,6 +397,7 @@ main() {
                restore_grouped_sessions  # also restores active and alt windows for grouped sessions
                restore_active_and_alternate_windows
                restore_active_and_alternate_sessions
+               cleanup_restored_pane_contents
                execute_hook "post-restore-all"
                stop_spinner
                display_message "Tmux restore complete!"

I have to mention that the plugin used to work perfectly when I was using bash, but it fails to restore pane contents using fish as the default shell. This patch fixed this issue for both bash and fish for me.

I tested on macos 12.1 using tmux 3.2a and fish 3.3.1.

@bruno- Sorry, you’re right about my last comment being unclear; I just reread it myself and it didn’t make sense until I read it yet again. Let me try to clarify:

What I mean is that whenever I use a version later than 7a8d90a, things are broken again. I.e., I’m currently stuck at 7a8d90a, because whenever I update (it doesn’t matter if I update to master, b7a4ee2, or anything else), I get the same old error when I try to restore my panes:

cat: /Users/me/.tmux/resurrect/restore/pane_contents//pane-0:0.0: No such file or directory

The pane_contents.tar.gz file seems to contain the right things though.

Sure.

diff --git a/scripts/restore.sh b/scripts/restore.sh
index 50d4cbb..11f852a 100755
--- a/scripts/restore.sh
+++ b/scripts/restore.sh
@@ -258,9 +258,9 @@ restore_all_panes() {
                        restore_pane "$line"
                fi
        done < $(last_resurrect_file)
-       if is_restoring_pane_contents; then
-               pane_content_files_cleanup
-       fi
+       # if is_restoring_pane_contents; then
+               # pane_content_files_cleanup
+       # fi
 }

 restore_pane_layout_for_each_window() {
diff --git a/scripts/save.sh b/scripts/save.sh
index 137e229..9edc425 100755
--- a/scripts/save.sh
+++ b/scripts/save.sh
@@ -264,7 +264,7 @@ save_all() {
                mkdir -p "$(pane_contents_dir)"
                dump_pane_contents
                pane_contents_create_archive
-               pane_content_files_cleanup
+               # pane_content_files_cleanup
        fi
        if save_bash_history_option_on; then
                dump_bash_history

Yeah I mean I wouldn’t even call it a workaround, doesn’t hurt any functionality and just brings pane_contents down to the same level as the rest of the plug, not cleaning up old unused files. Non-issue in both cases, but even more so here since any dangling files will just get overwritten anyways once you recreate a pane with the same index.