Open site shell works on PHP 7.4 but not on PHP 8.1 (Manjaro)

Bug Summary

OS: Linux Manjaro

When using PHP 8.1, when I click “Open site shell”, it opens the terminal as expected, but throws an error at shell startup. If I change to PHP 7.4, it works.

Setting Local environment variables...
----
WP-CLI:   WP-CLI 2.9.0
sh: symbol lookup error: sh: undefined symbol: rl_trim_arg_from_keyseq
Composer: 2.6.2 2023-09-03
PHP:      8.1.23
MySQL:    mysql  Ver 8.0.16 for Linux on x86_64 (MySQL Community Server - GPL)
----
Launching shell: /usr/bin/zsh ...
bash: symbol lookup error: bash: undefined symbol: rl_trim_arg_from_keyseq

Essentially, Bash is broken on that session because of the LD_LIBRARY_PATH override:

➜  public ldd /bin/bash                                                                                                                                                                                                    
/bin/bash: symbol lookup error: /bin/bash: undefined symbol: rl_trim_arg_from_keyseq

➜  public LD_LIBRARY_PATH='' ldd /usr/bin/bash                                                                                                                                                                             
        linux-vdso.so.1 (0x00007ffe6d1f8000)
        libreadline.so.8 => /usr/lib/libreadline.so.8 (0x00007fdb357ca000)
        libc.so.6 => /usr/lib/libc.so.6 (0x00007fdb355de000)
        libncursesw.so.6 => /usr/lib/libncursesw.so.6 (0x00007fdb3556f000)
        /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007fdb35977000)

By searching for “LD_LIBRARY_PATH” on Local directory, I can see that it overrides it at siteShellStartupPOSIX.

If I change the site PHP version from 8.1 to 7.4, it works.