HenrikBengtsson/CBI-software

Set default version and hide versions on some Linux distributions

HenrikBengtsson opened this issue · 2 comments

Use a MODULERC file to hide modules, hide specific versions, or set the default version, conditioned on which Linux distribution is used, e.g. centos7 or rocky8.

For example, OpenJDK 17 does not exist on CentOS 7, so there openjdk/11 should be the default, whereas on Rocky 8, openjdk/17 should be default. So, according to https://lmod.readthedocs.io/en/latest/093_modulerc.html#modulerc-label, I think one can do something like:

if os.getenv("_LINUX_DISTRO_") == "centos7" then
    module_version("openjdk/11", "default")
    hide_version("openjdk/17")
end

to make that the default version on CentOS 7 and also hide openjdk/17.

Setting the default version via module_version("foo/1.2.3", default") should be done in a .modulerc.lua file located in the foo/ folder, cf. https://lmod.readthedocs.io/en/latest/060_locating.html#marking-a-version-as-default. It does not work in the parent folder.

For example, I've verified that:

$ cat /path/to/openjdk/.modulerc.lua
if os.getenv("_LINUX_DISTRO_") == "centos7" then
    module_version("openjdk/11", "default")
end

will make openjdk/11 the default on CentOS 7, but otherwise not.

Hiding a specific versions works by putting a .modulerc.lua file anywhere in the "module tree", e.g.

$ cat /path/to/CBI/.modulerc.lua
if os.getenv("_LINUX_DISTRO_") == "rocky8" then
  hide_version("scl-devtoolset/4")
  hide_version("scl-devtoolset/7")
  hide_version("scl-devtoolset/8")
  hide_version("scl-devtoolset/9")
  hide_version("scl-devtoolset/10")
  hide_version("scl-devtoolset/11")
end

will hide all scl-devtoolset versions on Rocky 8. I've verified this.

I've also verified that it does not work to hide all versions at once using, say, hide_version("scl-devtoolset"), hide_version("scl-devtoolset/"), or similar.