BASH_FUNC environment variables reigning havoc and it just keeps getting worse

I’ve been researching a black screen bug for about a month now and ultimately find that this problem has been going on in one form or another for years. Here it is in a nutshell, from one of the comments:

Cause of this bug is simple - systemd don’t import ALL enviroment variables if any variable name is not POSIX compilant
(it must conform to the regex [0-9A-Z_], see: systemd/env-util.c at a859abf062cef1511e4879c4ee39c6036ebeaec8 · systemd/systemd · GitHub).

You can test it with this command: env %=1 systemctl --user import-environment, it will fail.

Now there is 2 known packages exporting those variables: environment-modules and Lmod.

Solution is simple - skip ONLY invalid variables while importing others.

I’ve created bug in the systemd, but still without answer - exporting bash functions as env vars are not compatible with systemctl's `--import-environment` operation · Issue #14878 · systemd/systemd · GitHub.

So, what we basically have is two projects lmod and environment-modules that create apparently non-compliant env variables that systemd won’t recognize. This in turn has caused and is continuing to cause a cascading trail of havoc. The correct way to fix this is either lmod and environment-modules change to a compliant naming scheme or systemd accept the names - or just skip the ones it doesn’t want to recognize. @mattdm I think we need some intervention here.

File a Fedora bug explaining the overall problem and nominate it as a potential prioritized bug. We’ll review and see what we can do.

Thanks. I created bug here: 1912046 – BASH_FUNC environment variables reigning havoc and it just keeps getting worse

We should be addressing the root cause rather than playing whack-a-mole.

1 Like

Yep, thanks. Continued conversation in that bug.