You should use different names for the variables you set with set, as setenv also changes them (in the module environment).
My suggestion, is use lowercase for the internal variables (set ) and uppercase for those you set with setenv.
Or, you could eliminate most of the set lines, since setenv also sets those variables (and additionally sets them in the shell).
This is from the man page for 3.2.10 (the binary version, if you are using the tclsh version, check you man page).
setenv variable value
Set environment variable to value. The setenv command will also change the process'
environment. A reference using Tcl's env associative array will reference changes made with
the setenv command. Changes made using Tcl's env associative array will NOT change the user's
environment variable like the setenv command. An environment change made this way will only
affect the module parsing process. The setenv command is also useful for changing the
environment prior to the exec or system command. When a modulefile is unloaded, setenv becomes
unsetenv. If the environment variable had been defined it will be overwritten while loading
the modulefile. A subsequent unload will unset the environment variable - the previous value
cannot be restored! (Unless you handle it explicitly ... see below.)
Unfortunately, that old version doe not have a pushenv command (which works differently).
On 1/27/2023 2:29 PM, Hernan Cervantes wrote:
> Hi there,
>
> I'm a new user, I have written some modulefile, but one environment
> variable is not being set in any way!
>
> the environment-module version is 3.2.10
>
> TCL_VERSION="8.5"
> TCL_PATCH_LEVEL="8.5.13"
>
> installed in a CentOS 7.9 computer.
>
> the modulefile content is:
> ==============
> #%Module 1.0
>
> set modulefilename "GROMACS"
> set modulefilever "5.1.5"
>
> # On load print component name and version being loaded
> if { [ module-info mode load ] } {
> puts stderr "Loading modeling program $modulefilename version $modulefilever"
> }
>
> # On `module unload` print component module and version being removed
> if { [ module-info mode ] == "unload" || [module-info mode ] == "remove" } {
> puts stderr "Removing $modulefilename version $modulefilever"
> }
>
> module-whatis "module whatis"
>
> ##########################################################
> # This is the real configuration part. We save the Gromacs
> # things in separate vars, so we can remove them later.
> # If you move gromacs, change the first line.
> ##########################################################
> set GMXPREFIX /opt/softwares/gromacs-5.1.5
> setenv GMXPREFIX $GMXPREFIX
>
> set GMXBIN $GMXPREFIX/bin
> setenv GMXBIN $GMXBIN
> setenv GMXBIN $GMXBIN
>
> set GMXLDLIB $GMXPREFIX/lib64
> setenv GMXLDLIB $GMXLDLIB
>
> set GMXMAN $GMXPREFIX/share/man
> setenv GMXMAN $GMXMAN
>
> set GMXDATA $GMXPREFIX/share/gromacs
> setenv GMXDATA $GMXDATA
>
> set GROMACS_DIR $GMXPREFIX
> setenv GROMACS_DIR $GROMACS_DIR
>
> prepend-path LD_LIBRARY_PATH $GMXLDLIB
> prepend-path PKG_CONFIG_PATH $GMXLDLIB/pkgconfig
> prepend-path PATH $GMXBIN
> prepend-path MANPATH $GMXMAN
>
> puts stderr "GMXBIN = $GMXBIN"
> if { [ file exist $GMXBIN/gmx-completion.bash ] } {
> puts stdout "source $GMXBIN/gmx-completion.bash"
> }
>
> set namepat $GMXBIN/gmx-completion-*.bash
> foreach cfile [ glob $namepat ] {
> puts stdout "source $cfile"
> }
>
> setenv GMXBIN $GMXBIN
> setenv GMXBIN $GMXBIN
> setenv GMXBIN $GMXBIN
> setenv GMXBIN $GMXBIN
> setenv GMXBIN $GMXBIN
> setenv GMXBIN $GMXBIN
> setenv GMXBIN $GMXBIN
> ===============
>
> the session transcription, in a bash shell, is:
> ======================
> [teste02@gfmm01 ~]$ echo $GMXBIN
>
> [teste02@gfmm01 ~]$ module load modelagem/example
> Loading modeling program GROMACS version 5.1.5
> GMXBIN = /opt/softwares/gromacs-5.1.5/bin
> [teste02@gfmm01 ~]$ echo $GMXBIN
>
> =====================
>
> What am I doing wrong?
>
> Thanks in advance.
>
> Hernán Cervantes
>
>
>
> _______________________________________________
> Modules-interest mailing list
> Mod...@li...
> https://lists.sourceforge.net/lists/listinfo/modules-interest
>
--
--------------------------------------------------------
The views and opinions expressed above are strictly
those of the author(s). The content of this message has
not been reviewed nor approved by any entity whatsoever.
--------------------------------------------------------
Paul FM Info: http://paulfm.com/~paulfm/
--------------------------------------------------------
|