Environment Modules (software)

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
Environment Modules
Stable release
5.6.1 / November 25, 2025; 4 months ago (2025-11-25)
Repository
  • {{URL|example.com|optional display text}}Lua error in Module:EditAtWikidata at line 29: attempt to index field 'wikibase' (a nil value).
Written inTcl
Engine
    Lua error in Module:EditAtWikidata at line 29: attempt to index field 'wikibase' (a nil value).
    Operating systemUnix-like
    LicenseGNU General Public License#Version 2
    Websiteenvmodules.io

    The Environment Modules system is a software tool designed to help users dynamically modify their shell environment. It provides a mechanism for managing and switching between sets of environment variable settings, often used to configure different software packages, compilers, and libraries.

    Overview

    [edit | edit source]

    Environment Modules allows users to dynamically configure their shell environment without permanently altering login scripts. This is especially useful in high-performance computing (HPC) environments where users may need to access multiple versions of the same application. Users load and unload scripts called modulefiles to modify environment variables such as PATH or LD_LIBRARY_PATH.

    Environment Modules is shell independent and supports all major Unix shells (Bash, ksh, Zsh, Fish, sh, tcsh, and csh), Windows shells (CMD.EXE and PowerShell) and several Scripting languages (Perl, Python, Ruby, Tcl, CMake and R)

    Environment Modules handles all kinds of items part of the shell environment, including environment variable, shell alias, shell function and command-line completion.

    History

    [edit | edit source]

    Environment Modules was first developed in the early 1990s[1] by John L. Furlani at Sun Microsystems. Version 1 was developed as pure shell scripts. With version 2 Environment Modules became a C program evaluating modulefiles written in Tcl.

    In the mid 1990s Peter W. Osel at Siemens and Jens Hamisch at Strawberry released the 3.0beta version.[2] R.K. Owen at the National Energy Research Scientific Computing Center (NERSC) took over the project in the late 1990s and ported it to Linux. He released version 3.1 in 2000 under the GNU General Public License (GPL).[3]

    During the 2000s, Environment Modules gained traction in the high-performance computing (HPC) world and started to be used at the largest computing centers.[4][5] Environment Modules was specified as a Baseline Configuration requirement of the DoD High Performance Computing Modernization Program (HPCMP).[6]

    In 2004, Mark Lakata of MIPS Technologies developed a pure Tcl reimplementation of Environment Modules.[7] Maintenance of this alternative version was later continued by Kent Mein at the University of Minnesota.

    In 2008, Robert McLay of the Texas Advanced Computing Center (TACC) introduced Lmod,[8] an alternative implementation project of Environment Modules written in Lua.

    After the release of version 3.2.10 in December 2012, development of the C implementation of Environment Modules was discontinued. In the following years, the Lmod project grew in popularity within the HPC community.

    In 2017, stewardship of the Environment Modules project was transferred to Xavier Delaruelle of the French Alternative Energies and Atomic Energy Commission (CEA). He released version 4, based on the pure Tcl implementation, which was adapted to maintain compatibility with the earlier C version.[9] Since then, new features have been introduced regularly to enhance usability and extend functionality.[10]

    In 2025, Modules became a Linux Foundation project part of the High Performance Software Foundation (HPSF).[11]

    Architecture

    [edit | edit source]

    Environment Modules provides the command modulecmd.tcl along with a shell function or alias named module.[12] The command interprets modulefiles,[13] scripts written in Tcl that define environment modifications, and produces the corresponding shell code. The shell function or alias then evaluates this code to update the current shell session accordingly.

    A modulefile typically modifies environment variables such as PATH, MANPATH, or LD_LIBRARY_PATH. The example below shows a simple modulefile for a sample software package:

    #%Module
    module-whatis {Example software version 1.2}
    
    set root /usr/local/example-1.2
    
    prepend-path PATH            $root/bin
    prepend-path LD_LIBRARY_PATH $root/lib
    append-path  MANPATH         $root/man
    

    Modulefiles are organized into directories known as modulepaths. These modulepaths can be centrally managed to provide system-wide access or placed in personal directories for user-specific configurations.

    Users can:

    • Load a modulefile (i.e., apply environment changes defined) using module load
    • Unload a modulefile (i.e., undo its environment changes) with module unload
    • Switch between modulefiles using module switch
    • View available modulefiles with module avail
    • Display content of a modulefile using module display
    • List currently loaded modulefiles with module list
    • Save currently loaded modulefiles in a collection using module save
    • Restore environment described by a collection with module restore
    • Enable a modulepath with module use

    Usage examples

    [edit | edit source]

    Create sample modulefiles in a user-specific modulepath:

    $ mkdir -p $HOME/privatemodules/test
    $ echo '#%Module' >$HOME/privatemodules/test/1.0
    $ echo '#%Module' >$HOME/privatemodules/test/2.0
    $ module use $HOME/privatemodules
    

    Viewing available modules:

    $ module avail
    ---- /home/user/privatemodules ---------------------------
    test/1.0  test/2.0
    
    ---- /usr/share/Modules/modulefiles ------------------------
    dot  module-git  module-info  modules  null  use.own
    

    Loading a module:

    $ module load test/2.0
    

    List loaded modules:

    $ module list
    Currently Loaded Modulefiles:
     1) test/2.0
    

    Switching versions:

    $ module switch test/2.0 test/1.0
    

    Unloading all loaded modules:

    $ module purge
    

    Define a default version for sample test module:

    $ echo '#%Module' >$HOME/privatemodules/test/.modulerc
    $ echo 'module-version test/1.0 default' >>$HOME/privatemodules/test/.modulerc
    

    Load default test module:

    $ module load test
    $ module list
    Currently Loaded Modulefiles:
     1) test/1.0
    

    Availability

    [edit | edit source]

    Environment Modules is distributed by a wide range of Linux and Unix operating systems.[14] It is available under the package name environment-modules in Debian, Ubuntu, Red Hat Enterprise Linux and Fedora. The software is also packaged for macOS through the Homebrew project, and a version is available for Windows systems. Where pre-packaged distributions are not provided, the project supplies source code and documentation to support manual installation and configuration.[15][16]

    References

    [edit | edit source]
    1. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    2. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    3. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    4. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    5. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    6. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    7. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    8. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    9. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    10. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    11. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    12. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    13. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    14. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    15. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    16. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    [edit | edit source]

    Lua error in mw.title.lua at line 392: bad argument #2 to 'title.new' (unrecognized namespace name 'Portal').