ble.sh icon indicating copy to clipboard operation
ble.sh copied to clipboard

[tmux-resurrect] Cache broken on restoring (Error `ble.sh: The keymap 'vi_imap' is empty.`)

Open RakibFiha opened this issue 3 years ago • 15 comments

ble version: 0.4.0-devel3+750ca38 Bash version: 5.0.17(1)-release (x86_64-pc-linux-gnu)

I am getting ble.sh: The keymap 'vi_imap' is empty. after restoring my tmux session, and ble.sh is not loading.

I am also unable to see any key press in the terminal, unless I do tput reset

RakibFiha avatar May 14 '21 08:05 RakibFiha

~I have went back to 0506df28baa6a and not getting this error.~

RakibFiha avatar May 14 '21 08:05 RakibFiha

I have went back to 0506df28baa6a and not getting this error.

Thank you for the report! Can you identify the commit where the problem starts by using binary search (or manual git bisect)?

akinomyoga avatar May 14 '21 08:05 akinomyoga

Weird!! After, rebuilding from latest master, it went away.

RakibFiha avatar May 14 '21 08:05 RakibFiha

Hmm, seems like, it only happens when tmux session is restored even for https://github.com/akinomyoga/ble.sh/commit/0506df28baa6ac54de6cb6650d2ad208b0c00190

I am using a plugin called tmux-resurrect with tpm.

RakibFiha avatar May 14 '21 08:05 RakibFiha

Weird!! After, rebuilding from latest master, it went away.

Ah, OK. I think it was because the keymap cache has been updated by switching the commit.

Actually, I recently experienced the same phenomena in my local testing once. I found that this is caused by an empty keymap cache file $_ble_base_cache/keymap.vi, but I couldn't find the reason why the file became empty and couldn't reproduce the same phenomena anymore. Now it seems you can reproduce the problem, I'd like to further collect the information.

Hmm, seems like, it only happens when tmux session is restored even for 0506df2

I am using a plugin called tmux-resurrect with tpm.

I'm actually not sure what tmux-resurrect does, but does it mean if you just reattach the tmux session without using tmux-resurrect, the problem doesn't reproduce?

akinomyoga avatar May 14 '21 09:05 akinomyoga

Persists tmux environment across system restarts.

tmux-resurrect allows to save a session, manually (prefix + ctr +s) or automatically at some interval. So, even after you kill that session, you can still get that session back (like panes, windows and so on). It makes it also possible to get the session back after reboot of machine.

RakibFiha avatar May 14 '21 09:05 RakibFiha

Thank you for the explanation. I'm looking at the manual of tmux-resurrect. Now I'm wondering if it tries to restore the Bash session as well (including the current directory, aliases, user-defined key-bindings, etc.) not only the tmux window layout? It says it restores the state of vi, emacs, etc. but doesn't mention bash which I think the most essential which is weird.

akinomyoga avatar May 14 '21 09:05 akinomyoga

Maybe it is different from the problem that I experienced before. I think I can try to set up tmux-resurrect tomorrow in my machine to see if the same problem reproduces. For now, could you see whether the file $_ble_base_cache/keymap.vi is empty when the problem is present?

$ ls -l "$_ble_base_cache/keymap.vi"

akinomyoga avatar May 14 '21 09:05 akinomyoga

Before resurrection

md5sum: 0b5037c79032706a9ae7858a3a920c7b ~/.cache/blesh/0.4/keymap.vi

not empty

After resurrection:

The error happens and nothing typed can be seen in the window. After tput reset the typing appears.

And, yes the ~/.cache/blesh/0.4/keymap.vi is empty. :)

RakibFiha avatar May 14 '21 09:05 RakibFiha

Thank you! OK... the cache file becomes indeed empty by tmux-resurrect. It's really puzzling that the cache file is affected by the resurrection... I'll try to find what's happening.

For the time being, If you want to soon use ble.sh, you can just delete the file $_ble_base_cache/keymap.vi every time when the problem started to happen.

akinomyoga avatar May 14 '21 09:05 akinomyoga

Hi, I have set up tmux-resurrect using tpm, saved a session with prefixC-s, and restored prefixC-r, but it just works without problems. I have questions:

  • Q1: Could you describe the precise procedure to reproduce the problem? I have tried prefix C-s (save session) prefix C-r (restore session) prefix c (create new window), but there seems to be no problems.

  • Q2: Does the problem occur without ~/.inputrc?

    $ cd
    $ mv .inputrc .inputrc.backup20210515
    $ tmux
    

    Try to reproduce the problem, e.g. prefix C-sprefix C-rprefix c, etc.

    After testing you can restore the .inputrc file.

    $ cd
    $ mv .inputrc.backup20210515 .inputrc
    
  • Q3: Does the problem occur without any configuration in .bashrc other than ble.sh? Similarly to the .inputrc case, you can rename your .bashrc to the temporary one, create a new ~/.bashrc with a single line source /path/to/ble.sh --norc, start tmux session, save and restore the state using tmux-resurrect. After the testing, you can restore your original .bashrc.

akinomyoga avatar May 15 '21 14:05 akinomyoga

I actually cannot reproduce it anymore. Not sure why.

But, yesterday the steps mentioned at Q1 would reproduce it. I will try again tomorrow.

Q2: Does the problem occur without ~/.inputrc?

Removing inputrc also is not reproducing it.

RakibFiha avatar May 15 '21 15:05 RakibFiha

Hmm, heisenbug... Have you changed your shell configuration or system configuration or updated some softwares since you last reproduced the problem?

akinomyoga avatar May 15 '21 15:05 akinomyoga

I'm looking at code and thinking of possible causes.

  • One possibility might be caused by wrong timestamps. Maybe, when you have tested it yesterday, the timestamps of some files have been set to the future time (but before now). Do you use NFS or SSHFS, or some other types of network drives? Or have you changed your system time recently (before you found the problem)?
  • Another possibility: I'm not sure if it really causes problem, but do you have several different versions of ble.sh installed on different directories?

akinomyoga avatar May 15 '21 15:05 akinomyoga

Hi, did the problem appeared again in your environment? It seems that the problem cannot be reproduced on my side. Nevertheless, I added a workaround for the phenomena of the vi_imap cache becoming empty in commit 560160b. Now ble.sh checks that the cache is non-empty before reading the cache file. This fix doesn't solve the root cause but is just a workaround for the resultant phenomena of the empty vi_imap cache, so possibly some other problems are still present. If you have noticed something additional, please let me know. Thank you!

akinomyoga avatar May 20 '21 10:05 akinomyoga