akinomyoga / ble.sh

Bash Line Editor―a line editor written in pure Bash with syntax highlighting, auto suggestions, vim modes, etc. for Bash interactive sessions.
BSD 3-Clause "New" or "Revised" License
2.33k stars 77 forks source link

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

Closed neilbags closed 1 month ago

neilbags commented 2 months ago

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?

akinomyoga commented 2 months ago

What is the output of the following command?

$ declare -p PS1
akinomyoga commented 2 months ago

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

akinomyoga commented 2 months ago

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?

neilbags commented 2 months ago

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 commented 2 months ago

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

akinomyoga commented 2 months ago

Thank you.

# 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.

neilbags commented 2 months ago

debug.blesh.GitHub442.txt

akinomyoga commented 2 months ago

Thank you.

# somewhere in blerc

ble/function#advice around ble/prompt/update 'prompt_unit="" ble/function#advice/do'
neilbags commented 2 months ago

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

akinomyoga commented 2 months ago

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 commented 1 month ago

@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?

neilbags commented 1 month ago

Seems all good

akinomyoga commented 1 month ago

Thank you!