Lmod is not available in Gentoo’s portage. This blog post will document how I got Lmod installed on my Gentoo machine.
First requirement is to install
lua. I picked lua 5.2 as I had problem when experimenting with Lua 5.1. To install
lua-5.2.3 from portage, run:
# emerge -av =dev-lang/lua-5.2.3
If you have multiple versions of Lua installed, make sure to select this lua 5.2.3 as the default version using
# eselect lua list  5.2 # eselect lua set 1
Lmod depends on 2 lua-libraries:
filesystem. Both of these libraries are available on Gentoo as packages
dev-lua/luafilesystem. However, those lua-packages depends on lua 5.1. So I have to find another way to install the required libraries.
Fortunately, we can use a package manager for Lua modules called LuaRocks. (And it does rock as its name!)
# emerge -av dev-lua/luarocks
After that we can proceed with the installation of the 2 lua-modules:
# luarocks install luaposix; luarocks install luafilesystem ... luaposix 34.0.4-1 is now built and installed in /usr/lib64/lua/luarocks ... luafilesystem 1.7.0-2 is now built and installed in /usr/lib64/lua/luarocks
Now, you have to make the the lua packages installed by luarocks to be known by lua. Let’s display the package path and shared libraries path:
$ lua -e 'print(package.path)' /usr/share/lua/5.2/?.lua;/usr/share/lua/5.2/?/init.lua;/usr/lib64/lua/5.2/?.lua;/usr/lib64/lua/5.2/?/init.lua;./?.lua $ lua -e 'print(package.cpath)' /usr/lib64/lua/5.2/?.so;/usr/lib64/lua/5.2/loadall.so;./?.so
Then you need to append
LUAROCKS_PREFIX to both
LUAROCKS_PREFIX=/usr/lib64/lua/luarocks export LUA_PATH="$LUAROCKS_PREFIX/share/lua/5.2/?.lua;$LUAROCKS_PREFIX/share/lua/5.2/?/init.lua;;" export LUA_CPATH="$LUAROCKS_PREFIX/lib/lua/5.2/?.so;;"
Before we could start building Lmod, there is just one more package needed to be installed.
# emerge -av dev-lang/tcl
Alright, we’re ready to start building Lmod. As of this writing, the latest Lmod version available is 7.8.20. Let’s get the source code and untar it. (I compile the Lmod source code as a non-privileged user.)
$ wget https://github.com/TACC/Lmod/archive/7.8.20.tar.gz $ tar xzvf 7.8.20.tar.gz $ cd Lmod-7.8.20
In my case, I picked Lmod to be installed to
./configure --prefix=/opt ... BASH_ENV is defined both in: /opt/lmod/7.8.20/init/profile /opt/lmod/7.8.20/init/cshrc ... Configure complete, Now do: $ make install # -> A complete install or $ make pre-install # -> Install everything but the symbolic link $ sudo -E make install
I’m using ZSH-shell, and to get lmod loaded when a shell is opened, I need to append the following ine to the
# Source lmod if [[ -s /opt/lmod/lmod/init/profile ]]; then source /opt/lmod/lmod/init/profile fi
As the last step, let’s verify if the installation is working:
❯❯❯ type module module is a shell function from /opt/lmod/lmod/init/zsh ❯❯❯ echo $LMOD_CMD /opt/lmod/lmod/libexec/lmod ❯❯❯ echo $MODULEPATH /opt/modulefiles/Linux:/opt/modulefiles/Core:/opt/lmod/lmod/modulefiles/Core
There seems to be a lot work to get Lmod installed, but hey I learned quite a bit during this short journey.