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

why should we add /etc/profile.d/*.sh to /etc/bash.bashrc? #677

Closed simonLeary42 closed 11 months ago

simonLeary42 commented 1 year ago

https://lmod.readthedocs.io/en/latest/030_installing.html?highlight=LMOD_SITE_MODULEPATH#bash-under-ubuntu

Sites that run Ubuntu and have bash users should consider adding the following to their /etc/bash.bashrc:

...

This is useful because non-login interactive shells only source /etc/bash.bashrc and this file doesn’t normally source the files in /etc/profile.d/*.sh.

Why would a non-login interactive shell not simply inherit the module function and other environment variables from its parent login shell? I thought there was an assumption in bash that all shells must start with a login shell and that login environment will always propogate unless explicitly disabled.

rtmclay commented 1 year ago

There are many ways to get a non-login interactive shells. Logging on to a remote node via ssh may or may not be a login shell. It depends on how bash is setup. But the one that comes up the most in the HPC world is MPI startup on remote nodes. There is no login shell to inherit from. The problem is that the bash that redhat uses does not load /etc/bashrc (or /etc/bash.bashrc). It expects the user's ~/.bashrc to source /etc/bashrc. This is an extremely idiotic to expect most users to know why that line is necessary. That is why at TACC, we patch bash.

rtmclay commented 11 months ago

O.K. to close this issue?