Hello Baudilio,
Error messages can be overridden with site-specific configuration script
siteconfig.tcl [1].
In this Tcl script file, you can supersede the definition of the procedure
that report error messages (reportError), to change the implicit default
error message.
$ cat /etc/environment-modules/siteconfig.tcl
rename __reportError __reportError_ORIG
proc __reportError {message {severity ERROR} {sgrkey er} {incr_count 1}} {
if {[regexp {No default version defined for '(.*)'} $message match
mod]} {
append message "\nHINT: Type 'module avail $mod' to get available
versions"
}
__reportError_ORIG $message $severity $sgrkey $incr_count
}
$ module config implicit_default 0
$ module load foo
ERROR: No default version defined for 'foo'
HINT: Type 'module avail foo' to get available versions
Regards,
Xavier
[1]
https://modules.readthedocs.io/en/latest/module.html#site-specific-configuration
Le sam. 13 janv. 2024 à 17:38, Paul Markfort <pau...@gm...> a écrit :
>
> Why would a user do this (except for testing)?
> The error they get is obvious (once you understand what the implicit
> setting does).
> Enforcing it, is overkill.
>
>
> I think the second best option is to define EXPLICIT defaults for your
> modules.
> The best, is to just educate your users as to what implicit default does
> (and that they probably don't want to turn it off).
>
>
>
> MODULES_IMPLICIT_DEFAULT
> Defines (if set to 1) or not (if set to 0) an implicit
> default version for modules without a default version explicitly defined
> (see
> Locating Modulefiles section in the modulefile man page).
>
> Without either an explicit or implicit default version
> defined a module must be fully qualified (version should be specified in
> addi-
> tion to its name) to get:
>
> • targeted by module load, switch, display, help, test and
> path sub-commands.
>
> • restored from a collection, unless already loaded in
> collection-specified order.
>
> • automatically loaded by automated module handling
> mechanisms (see MODULES_AUTO_HANDLING section) when declared as module
> require-
> ment, with prereq or module load modulefile commands.
>
> An error is returned in the above situations if either no
> explicit or implicit default version is defined.
>
>
> On 1/13/2024 9:50 AM, Baudilio Tejerina - NOAA Affiliate via
> Modules-interest wrote:
> > Hello,
> >
> > We need to enforce ‘implicit_default’ at out site.
> >
> > Is it possible to catch errors such as
> >
> > $ module config implicit_default 0
> > $ module load foo
> > ERROR: No default version defined for 'foo'
> >
> >
> > so that that I can inform users with possible, alternative, available
> actions?
> >
> >
> > Thank You!
> > Baudilio
>
>
|