Repository: easybuilders/easybuild-framework

Issue:
easybuild and module versions
Dear Group
I am exploring the use of easybuild on a newly built test Ubuntu 20.04 node. When I went **eb GCC** I get an error
**ERROR: Failed to determine Environment Modules v3 version from option '--version' output: Modules Release 4.4.1 (2020-01-03)**
and I found that **module --version** produces different formatted outputs between two different versions on two different OSs. Ubuntu had version 4.4.1 and a Centos box had version 3.2.10.  The easybuild code consists of:

> NAME = "Environment Modules v3"
>     COMMAND = "modulecmd"
>     REQ_VERSION = '3.2.10'
>     MAX_VERSION = '3.99'
>     VERSION_REGEXP = r'^\s*(VERSION\s*=\s*)?(?P<version>\d\S*)\s*'

So does mean Easybuild can't be used with this version of **modules** (4.4.1)? If it can, can you advise me how to configure it so that it will work on Ubunutu.
thanks Simon


Discussion:
@smichnowicz you can explicitly tell easybuild which module tool and syntax to use with e.g. `--modules-tool=EnvironmentModules` (https://docs.easybuild.io/en/latest/Configuration.html#modules-tool-modules-tool) and `--module-syntax=Tcl` (https://docs.easybuild.io/en/latest/Configuration.html#module-files-syntax-module-syntax)

see e.g. https://easybuilders.github.io/easybuild-tutorial/2021-isc21/configuration/#modules-tool-module-syntax

(once you use the command line options to test that it's working, you can set them more permanently with environment variables or configuration files, https://docs.easybuild.io/en/latest/Configuration.html)
Miguel, Thanks for the answer, but I have this in my config file
**modules-tool: EnvironmentModulesC  
module-syntax: Tcl**

And I specified it as a command line
 **eb --modules-tool=EnvironmentModulesC --module-syntax=Tcl GCC**
_== Temporary log file in case of crash /tmp/eb-8d02gcdc/easybuild-xgyiyyp_.log
ERROR: Failed to determine Environment Modules v3 version from option '--version' output: Modules Release 4.4.1 (2020-01-03)_

The code indicates that it can not handle a modules version > 3.99. The regex will not scan `modules --version` from version 4.4.1


regards
Simon
`EnvironmentModulesC` refers to version 3, use `EnvironmentModules` (https://docs.easybuild.io/en/latest/Configuration.html#modules-tool-modules-tool)
Thanks . I think using **EnvironmentModules** will fix it. It still crashes as it can not find modulecmd.tcl  (which is in /usr/lib/x86_64-linux-gnu/modulecmd.tcl) and MODULESHOME points to /usr/share/Modules.  I will need to work out how to resolve this.
regards
Simon

> Thanks . I think using **EnvironmentModules** will fix it. It still crashes as it can not find modulecmd.tcl (which is in /usr/lib/x86_64-linux-gnu/modulecmd.tcl) 

it should be enough to add `/usr/lib/x86_64-linux-gnu/` to `$PATH`



I have the same error. Even after adding `/usr/lib/x86_64-linux-gnu/` to `$PATH`, eb still keeps looking for `/usr/share/modules/libexec/modulecmd.tcl` specifically. Same, ubuntu 20.04.
hm, indeed, for `EnvironmentModules`, v4.x, eb expects `modulecmd.tcl` to be at `$MODULESHOME/libexec` [1] and the way Ubuntu (/Debian?) packages it [2] there is no `libexec` dir...

@smichnowicz were you able to get around this?

@rsarm as a workaround for now, create a link? (or use Lmod?)

[1] https://github.com/easybuilders/easybuild-framework/blob/dec669c589be4ca39d4b977412b2308b1a6b27d6/easybuild/tools/modules.py#L1317
[2] https://ubuntu.pkgs.org/20.04/ubuntu-universe-amd64/environment-modules_4.4.1-1_amd64.deb.html
Thanks @migueldiascosta! I will move to Lmod.
Miguel, 
 the only way to proceed would be  for me to copy the modulecmd.tcl to where easybuild was expecting it.  I have not tested this yet, as this  would meet a lot of resistance from fellow sysadmins if I were to do this on a cluster wide scale. regards Simon
@smichnowicz I see, we need to fix that

meanwhile, I suppose you could copy the contents of `$MODULESHOME` to your home folder, reset `$MODULESHOME` to that path, create a `libexec` folder and copy `modulecmd.tcl` there (?)

or install Lmod locally

Resolving patch:
diff --git a/easybuild/tools/modules.py b/easybuild/tools/modules.py
--- a/easybuild/tools/modules.py
+++ b/easybuild/tools/modules.py
@@ -187,7 +187,6 @@ def __init__(self, mod_paths=None, testing=False):
                 self.cmd = env_cmd_path
                 self.log.debug("Set %s command via environment variable %s: %s",
                                self.NAME, self.COMMAND_ENVIRONMENT, self.cmd)
-            # check whether paths obtained via $PATH and $LMOD_CMD are different
             elif cmd_path != env_cmd_path:
                 self.log.debug("Different paths found for %s command '%s' via which/$PATH and $%s: %s vs %s",
                                self.NAME, self.COMMAND, self.COMMAND_ENVIRONMENT, cmd_path, env_cmd_path)
@@ -1315,6 +1314,7 @@ class EnvironmentModules(EnvironmentModulesTcl):
     """Interface to environment modules 4.0+"""
     NAME = "Environment Modules v4"
     COMMAND = os.path.join(os.getenv('MODULESHOME', 'MODULESHOME_NOT_DEFINED'), 'libexec', 'modulecmd.tcl')
+    COMMAND_ENVIRONMENT = 'MODULES_CMD'
     REQ_VERSION = '4.0.0'
     MAX_VERSION = None
     VERSION_REGEXP = r'^Modules\s+Release\s+(?P<version>\d\S*)\s'


Test patch: