Environment Modules can't find installed modules
Matthew Harrington
I'm trying to install and load several Perl modules in Google Colab (a Ubuntu environment). I'm installing them with CPAN, then loading them with Environment Modules. I absolutely need to use Environment Modules to load them (for example, one of the commands that my script runs is module load Perl), but I don't need to use CPAN to install them if there's a better option.
First I installed the Perl modules with CPAN:
PERL_MM_USE_DEFAULT=1 cpan GD ExtUtils::PkgConfig DBI DBD::mysql DBD::SQLite Capture::Tiny Exporter Log::Message::Simple Getopt::Long \ List::Util List::MoreUtils IO::File XML::Writer XML::LibXML XML::Parser XML::LibXML::Reader \ Data::Dumper File::Slurp JSON Storable Scalar::Util Array::Utils Config::IniFiles \ Statistics::Descriptive GD::Graph::boxplotThen, running perldoc perllocal gave me the following:
Tue Jul 28 01:16:13 2020: "Module" App::cpanminus * "installed into: /usr/local/share/perl/5.26.1" * "LINKTYPE: dynamic" * "VERSION: 1.7044" * "EXE_FILES: bin/cpanm" Tue Jul 28 01:16:30 2020: "Module" Net::SSLeay * "installed into: /usr/local/share/perl/5.26.1" * "LINKTYPE: dynamic" * "VERSION: 1.88" * "EXE_FILES: " Tue Jul 28 01:16:32 2020: "Module" Mozilla::CA * "installed into: /usr/local/share/perl/5.26.1" * "LINKTYPE: dynamic" * "VERSION: 20200520" * "EXE_FILES: "
...However, when I run source /etc/profile.d/modules.sh && module avail to list the modules available for loading, the ones I just installed don't show up, and I only get the following (not sure why the same thing prints twice):
------------------------ /usr/share/modules/modulefiles ------------------------
dot module-git module-info modules null use.own
------------------------ /usr/share/modules/modulefiles ------------------------
dot module-git module-info modules null use.own So I figured that I need to add /usr/local/share/perl/5.26.1 to the modulepath for it to find the installed modules. But when I try to do this with module use --append /usr/local/share/perl/5.26.1 and then run module avail again, I get the same output as above, indicating that this directory hasn't been added.
1 Answer
Environment Modules works with modulefiles, which are scripts written in Tcl that describe environment changes (like the addition of a directory to an environment variable).
You could look at /usr/share/modules/modulefiles/dot on your setup to see an example of modulefile.
In your situation, you install Perl modules, but once installed there is no modulefile to bridge them in the Environment Modules context.
Their may be a confusion here between Environment Modules and Perl modules. Environment Modules may help to define an environment variable to reach the perl modules you have installed (for instance by adding the /usr/local/share/perl/5.26.1 directory to the PERL5LIB environment variable, see perllocal modulefile example below) but Environment Modules will not give you the visibility of the Perl modules you have installed.
/usr/share/modules/modulefiles/perllocal:
#%Module
append-path PERL5LIB /usr/local/share/perl/5.26.1 2