Simple to use Environment Modules

Simple to use Environment Modules

Environment Modules Introduction

Typically users initialize their environment when they log in by setting environment information for every application they will reference during the session. The Environment Modules package is a tool that simplify shell initialization and lets users easily modify their environment during the session with modulefiles.

Download and install

Download URL

installation steps

$ INSTALL.txt

$ ./configure
$ make
$ make install

The default installation directory

/usr/local/Modules
├── bin
│   ├── add.modules
│   ├── envml
│   ├── mkroot
│   └── modulecmd
├── etc
│   └── siteconfig.tcl
├── init
│   ├── bash
│   ├── bash_completion
│   ├── cmake
│   ├── csh
│   ├── fish
│   ├── fish_completion
│   ├── ksh
│   ├── ksh-functions
│   ├── lisp
│   ├── modulerc
│   ├── perl.pm
│   ├── profile-compat.csh
│   ├── profile-compat.sh
│   ├── profile.csh
│   ├── profile.sh
│   ├── python.py
│   ├── r.R
│   ├── ruby.rb
│   ├── sh
│   ├── tcl
│   ├── tcsh
│   ├── tcsh_completion
│   ├── zsh
│   └── zsh-functions
├── lib
│   └── libtclenvmodules.so
├── libexec
│   ├── modulecmd-compat
│   └── modulecmd.tcl
├── modulefiles
│   ├── dot
│   ├── module-git
│   ├── module-info
│   ├── modules
│   └── gcc
└── share
    ├── doc
    └── vim

initialization

Just installed Environment Modulesis not modulethis shell command
requires a simple configuration sourceof scene

  • In profile.destablishing the connection under the soft, execute the following statement
# root用户
$ cd /etc/profile.d
$ ln -s /usr/local/Modules/init/profile.sh
$ ln -s /usr/local/Modules/init/profile.csh

# 普通用户
$ source ~/.bashrc

$ which module
module is a function
module () 
{ 
    _module_raw "$@" 2>&1
}

Different version management tools

A simple example

$ cd /usr/local/Modules/modulefiles
$ mkdir riscv_toolchain
$ cd riscv_toolchain
$ touch compile-version
$ touch freedomstudio-version
  • compile-verison
#%Module1.0######################################################################
##
## riscv-toolchain modulefile
##
proc ModulesHelp { } {
    puts stderr "\tThe riscv-toolchain compile version Module\n"
    puts stderr "\tThis module adds the current working directory to your path."
}

module-whatis   "adds  /opt/riscv/toolchain/bin to your PATH environment variable"

conflict        riscv_toolchain/freedomstudio-version

set             riscv_home      /opt/riscv/toolchain
setenv          RISCV           $riscv_home

append-path     PATH            $riscv_home/bin
append-path     LIBRARY_PATH    $riscv_home/lib
append-path     LD_LIBRARY_PATH $riscv_home/lib
append-path     LD_INCLUDE_PATH $riscv_home/include
append-path     MANPATH         $riscv_home/share/man
  • freedomstudio-verison
#%Module1.0######################################################################
##
## riscv-toolchain modulefile
##
proc ModulesHelp { } {
    puts stderr "\tThe riscv-toolchain compile version Module\n"
    puts stderr "\tThis module adds the current working directory to your path."
}

module-whatis   "adds /opt/FreedomStudio/SiFive/riscv64-unknown-elf-gcc-8.3.0-2019.08.0 to your PATH environment variable"

conflict        riscv_toolchain/compile-version

set             riscv_home      /opt/FreedomStudio/SiFive/riscv64-unknown-elf-gcc-8.3.0-2019.08.0
setenv          RISCV           $riscv_home

append-path     PATH            $riscv_home/bin
append-path     LIBRARY_PATH    $riscv_home/lib
append-path     LD_LIBRARY_PATH $riscv_home/lib
append-path     LD_INCLUDE_PATH $riscv_home/include
append-path     MANPATH         $riscv_home/share/man

Simple to use

$ module load riscv_toolchain/compile-version
$ which riscv64-unknown-elf-gcc
riscv64-unknown-elf-gcc is /opt/riscv/toolchain/bin/riscv64-unknown-elf-gcc

$ module load riscv_toolchain/freedomstudio-version 
Loading riscv_toolchain/freedomstudio-version
  ERROR: riscv_toolchain/freedomstudio-version cannot be loaded due to a conflict.
    HINT: Might try "module unload riscv_toolchain/compile-version" first.

$ module unload riscv_toolchain/compile-version 

$ module load riscv_toolchain/freedomstudio-version 
$ which riscv64-unknown-elf-gcc
riscv64-unknown-elf-gcc is /opt/FreedomStudio/SiFive/riscv64-unknown-elf-gcc-8.3.0-2019.08.0/bin/riscv64-unknown-elf-gcc

Personal Environmental Management

$ cd ~/
$ mkdir privatemodules/

~/privatemodules/And /usr/local/Modules/modulefilescan still contain the local environment settings

Common Commands

Guess you like

Origin www.cnblogs.com/OneFri/p/11723628.html