Skip to content

Environment Modules

Environment modules is how we are able to provide one installation of a piece of software to an entire cluster and its user base. Modules also allow us to have infinite versions of a single piece of software without conflicts. A module is a piece of software that the user can load in his/her shell, and then have access to that software. The software is installed elsewhere, but is not available until the user loads it. Unity uses lmod for managing modules.

How it Works

You can skip this part if you don't care about how it works, but it may allow you to gain a better understanding for future reference.
Environment modules work by modifying the user's environment. The user's environment has a number of variables set. To see them all, just run env in the cli if you are curious. Those variables dictate what the user has access to. For instance, consider the $PATH environment variable. This variable is what determines where to find executable binaries. For example, when you run the command ls to list the directory, ls is simply an executable that lies somewhere on the system. In this case, /bin. Ordinarily, to run the ls executable, you would need to reference it directly, ie /bin/ls. To simplify this, linux adds certain directories to the $PATH environment variable. Any binaries/executable contained within any directories defined in $PATH can be executed from anywhere directly, ie ls. As such, /bin, /usr/bin, /usr/local/bin, etc. are all members of the $PATH variable.

Modulefiles work by manipulating these variables. For example, consider python, a binary that comes with almost all linux distributions these days. Usually, running python will execute the python that is installed on the system. But if we wanted to create a module which loads a different python, we would add the location of the different python into the environment variables, at the top of the list. Now, when you run python, the first entry in $PATH directs you to the module you loaded, and it loads that, even though a system python exists later on. The important thing is that the program you want to use is first in the variable.

To see physical examples of modulefiles, please visit this page.