TACC / Lmod

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

Make MODULESPATH_INIT variable changeable for scripts #648

Closed RuedigerLudwig closed 1 year ago

RuedigerLudwig commented 1 year ago

Hello,

The isn't a bug per se, but more of an enhancement.

The path for the .modulespath file is hard coded into the profile scripts as MODULEPATH_INIT="@modulepath_init@"

It might be an improvement if it would be possible to alternatively set the variable in a script that is sourced before the lmod profile script. This behavior is already possible with MODULEPATH_ROOT. That way it would be possible to use a file that is located outside the directory structure which gets replaced during an update.

If done as 'set to default if not set already' it would not change the current behavior.

Thanks for considering this.

Rüdiger

rtmclay commented 1 year ago

There was a suggestion on the mailing list to do the following:

Put in under /etc/lmod (or something you like that).

And then create the lmod config file: /etc/lmod/lmod_config.lua
with contents:

require("strict")
local cosmic = require("Cosmic"):singleton()
cosmic:assign("LMOD_MODULEPATH_INIT", "/etc/lmod/modulespath")

In general, this idea is a good thing to do. Sites can modify the behavior of Lmod by having /etc/lmod/lmod_config.lua do this.

However, in this case. The above won't work to set LMOD_MODULEPATH_INIT as this variable is only used in the startup file that typically goes into a site's /etc/profile.d and is used before Lmod even starts.

So, with the just released Lmod 8.7.24 sites can use the following choices to find the .modulespath file. The following is searched in order and the first found is used.

  1. /etc/lmod/.modulespath
  2. $LMOD_MODULESPATH_INIT (must be set before /etc/profile.d/z00_lmod.sh or similar is sourced during shell startup)
  3. Configure Lmod with --with-ModulePathInit=... or default location.

Please see the lmod documents for more information. Also please test Lmod 8.7.24 to see if it works for you.

rtmclay commented 1 year ago

There have been some improvement to support .modulepath. Please test Lmod 8.7.25 to see if works for you.

rtmclay commented 1 year ago

O.K. to close this issue?

RuedigerLudwig commented 1 year ago

Hello Robert, sorry for not answering. I was in a different project and was notable to check until now. Yes, I think the solution in 8.7.25 is perfect for my case so this can be closed now. Thank you very much Rüdiger