easybuild-framework
easybuild-framework copied to clipboard
Incorrect handling of XDG_DATA_DIRS
In #3133 a mechanism for modifying XDG_DATA_DIRS was added. However, the logic used there has undesired consequences on systems where XDG_DATA_DIRS is undefined (or empty). According to the XDG Base Directory spec:
If
$XDG_DATA_DIRSis either not set or empty, a value equal to/usr/local/share/:/usr/share/should be used.
EasyBuild simply prepends to the variable and thus overrides the implicit default value of /usr/local/share/:/usr/share/ if XDG_DATA_DIRS is undefined before loading a module that wants to prepend to it.
On one of our systems this leads to Emacs not working if certain modules are loaded, because it can no longer find icons for the GUI.
A better approach for setting XDG_DATA_DIRS would be to check if it is set to a non-empty value and prepend to it if it is, initialize to the implicit default /usr/local/share/:/usr/share/ and prepend to that if it is not.
Thanks a lot for the bug report @bsteinb! We'll try and get that sorted out.
That may not be trivial though, since the logic to decide whether we should add /usr/local/share/:/usr/share/ first needs to go in the generated module file...
we have lua code in a module that is always loaded (gentoo or nixpkgs):
if os.getenv("XDG_DATA_DIRS") then
prepend_path("XDG_DATA_DIRS", pathJoin(root, "usr/share"))
else
setenv("XDG_DATA_DIRS", pathJoin(root, "usr/share") .. ":/usr/local/share:/usr/share")
end
if os.getenv("XDG_CONFIG_DIRS") then
prepend_path("XDG_CONFIG_DIRS", pathJoin(root, "etc/xdg"))
else
setenv("XDG_CONFIG_DIRS", pathJoin(root, "etc/xdg") .. ":/etc/xdg")
end
I'm not sure if that would work for EB in general though. A system in general could initialize XDG_DATA_DIRS (to /etc/xdg) and XDG_CONFIG_DIRS (to /usr/local/share:/usr/share when setting up Lmod or similar).
On our build node the issue is sidestepped also by the existence of flatpak which has this file:
[oldeman@build-node ~]$ rpm -qf /etc/profile.d/flatpak.sh
flatpak-1.0.9-9.el7_7.x86_64
[oldeman@build-node ~]$ cat /etc/profile.d/flatpak.sh
# /etc/profile.d/flatpak.sh - set XDG_DATA_DIRS
if [ "${XDG_DATA_DIRS#*flatpak}" = "${XDG_DATA_DIRS}" ]; then
XDG_DATA_DIRS="${XDG_DATA_HOME:-"$HOME/.local/share"}/flatpak/exports/share:/var/lib/flatpak/exports/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
fi
export XDG_DATA_DIRS