TACC / Lmod

Lmod: An Environment Module System based on Lua, Reads TCL Modules, Supports a Software Hierarchy
http://lmod.readthedocs.org
Other
499 stars 128 forks source link

Bash shell startup can stall for a visible amount of time due to init/bash.in trying to run 'compinit -c' #725

Closed siebenmann closed 1 month ago

siebenmann commented 2 months ago

Describe the bug

Lmod bash initialization attempts to run 'compinit -c' if your system also has zsh installed, which can trigger Bash's command not found' handling, which can stall for significant amounts of time, stalling shell startup. The 'compint -c' invocation comes in __build_FPATH_for_zsh_ksh, which is invoked later in init/bash.in if your shell is ksh or Bash. In Bash, which has no compinit builtin, this can trigger an existing Bash command_not_found_handle function if one has been set up earlier in the shell startup process. An environment where this happens is Fedora 40 with the PackageKit-command-not-found package installed, which installs a command not found handler that will run '/usr/libexec/pk-command-not-found', which can take ten seconds or more.

(I have not attempted to reproduce this with the latest Lmod release; Fedora currently ships 8.7.48, but the init/bash.in code looks unchanged between the two versions and the Git tip.)

Reproduction

It's likely that this happens only the first time you log in (either system-wide or for a particular user using Bash as their login shell), which will mean you'll want to reproduce this in a VM that you can reboot freely. To reproduce you'll need a Fedora 40 environment with a user who has Bash as their shell and can be logged in over ssh; this Fedora 40 environment should have Lmod, PackageKit-command-not-found, and zsh all installed. With this setup, (re)boot the VM and log in over SSH as your target user. Observe the visible startup stall. Add instrumentation to /usr/share/lmod/lmod/init/bash to clearly identify the source of the stall.

rtmclay commented 2 months ago

I have updated the branch IS718-FPATH to change it so that only zsh calls compinit -C. Please test this branch to see if it works for you.

siebenmann commented 2 months ago

Unfortunately I'm not in a position to test this. I don't use Lmod myself; it was installed on my Fedora 40 machine through defaults (or so I assume), and so I'm not up to manually installing a non-RPM version.

rtmclay commented 1 month ago

Thank you for submitting this bug report. I have an even better solution in the next release of Lmod. Closing this issue. Thanks!