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

[WINCH in ble/prompt/update] Cyclic dependency error

Open neilbags opened this issue 9 months ago • 10 comments

Sometimes when opening my terminal, I see this error 3 times: ble/prompt: FATAL: detected cyclic dependency (_ble_prompt_ps1 required by _ble_prompt_ps1)

It doesn't seem to cause any issues but is annoying.

Here are my version details:

GNU bash, version 5.2.15(1)-release (x86_64-pc-linux-gnu) [Debian GNU/Linux 12 (bookworm)] ble.sh, version 0.4.0-devel4+70a325f (noarch) [git 2.39.2, GNU Make 4.3, GNU Awk 5.2.1, API 3.2, PMA Avon 8-g1, (GNU MPFR 4.2.0, GNU MP 6.2.1)] atuin, version 18.1.0 (/usr/bin/atuin) locale: LANG=en_AU.UTF-8 terminal: TERM=xterm-256color wcwidth=15.0-west/15.1-2+ri, vte:7006 (65;7006;1)

In my .bashrc I have this line at the top:

[[ $- == *i* ]] && source ~/.local/share/blesh/ble.sh --noattach

And this at the bottom:

[[ ${BLE_VERSION-} ]] && ble-attach
if [[ $(command -v atuin) ]]; then
  eval "$(atuin init bash --disable-up-arrow)"
fi

Can anyone help?

neilbags avatar Apr 27 '24 22:04 neilbags

What is the output of the following command?

$ declare -p PS1

akinomyoga avatar Apr 27 '24 22:04 akinomyoga

If you have custom ble.sh settings in ~/.blerc (or ~/.config/blesh/init.sh or other files), could you provide us with them?

akinomyoga avatar Apr 27 '24 22:04 akinomyoga

There was a similar report at #359.

Both seem to happen only on the startup. One possibility is that the terminal resizes the size of PTY after the shell starts on its startup, which causes the nested evaluation of the prompt via the WINCH trap. I'm not sure if this is actually the culprit in your case, but I added a workaround for it in commit 61968497. Could you update ble.sh by running ble-update and see if the behavior changes?

akinomyoga avatar Apr 27 '24 23:04 akinomyoga

Hi,

My PS1 is super weird because I'm using powerline-shell.

I haven't run ble-update yet but am unable to reproduce the issue at present - I'm not sure what has changed. The theory about the terminal resizing the PTY seems reasonable - I'm using a tiling extension for GNOME

If the error comes back I'll try doing an update

neilbags avatar Apr 29 '24 00:04 neilbags

Update - I'm still seeing the issue occasionally, even after ble-update

neilbags avatar Apr 29 '24 00:04 neilbags

Thank you.

  • Q3: I'd like to take a stack dump. Can you put the following code in your ~/.blerc and try to replicate the issue? After an issue happens, could you check if a file ~/debug.blesh.GitHub442.txt is created, and if present, attach the file to this issue? You can attach a .txt file in GitHub Issue by dragging and dropping the file into the text area.
# blerc

# Test code 1
function blerc/github442/test1 {
  [[ ${ADVICE_WORDS[1]} == *'(_ble_prompt_ps1 required by _ble_prompt_ps1)'* ]] || return
  (
    shopt -s extdebug
    shopt -s extglob
    ble-stackdump
    declare -p "${!_ble_prompt_ps1@}" $(compgen -vX '@([_A-Z]*|bleopt_)*')
  ) >> ~/debug.blesh.GitHub442.txt
}
ble/function#advice around ble/util/print blerc/github442/test1

After testing and attaching the file, you can remove the above test code from ~/.bashrc and delete the file ~/.debug.blesh.GitHub442.txt.

akinomyoga avatar Apr 29 '24 03:04 akinomyoga

Thank you.

  • Q4: Is the problem fixed by putting the following line in ~/.blerc? Since the problem seems to happen only occasionally, can you use this setting for a while to check if the situation changes?
# somewhere in blerc

ble/function#advice around ble/prompt/update 'prompt_unit="" ble/function#advice/do'

akinomyoga avatar May 01 '24 10:05 akinomyoga

Its been happening really consistently today (which is weird, and inconsistent with previous behavior), but its seems to have stopped since I put this in the config.

So far so good

neilbags avatar May 01 '24 10:05 neilbags

Thank you for checking! I'll push a proper fix to the master branch after waiting for a few days. If you face the problem again, please let me know!

akinomyoga avatar May 01 '24 11:05 akinomyoga

@neilbags Sorry for the delay. I've pushed the mentioned proper fix to the master branch. Now I think the workaround I provided in https://github.com/akinomyoga/ble.sh/issues/442#issuecomment-2088281175 is no longer needed. Could you check the behavior by updating ble.sh by running ble-update in a ble.sh session?

akinomyoga avatar May 15 '24 12:05 akinomyoga

Seems all good

neilbags avatar May 20 '24 00:05 neilbags

Thank you!

akinomyoga avatar May 20 '24 02:05 akinomyoga