简体   繁体   English

modulefile - 模块卸载不会取消设置环境变量

[英]modulefile - module unload is not unsetting environment variables

I have a very simple modulefile:我有一个非常简单的模块文件:

#%Module1.0#####################################################################
puts stderr "Loading personal environment"
proc ModulesHelp { } {
    puts stderr "\tLoads personal environment"
    puts stderr ""
}
setenv MYTEMPVAR sometext

And here is my command line:这是我的命令行:

> env | grep MYTEMPVAR
> module load ~/wa/example_modulefile
Loading personal environment
> env | grep MYTEMPVAR
MYTEMPVAR=sometext
> module unload ~/wa/example_modulefile
> env | grep MYTEMPVAR
MYTEMPVAR=sometext

According to the modulefile man page unload module command was supposed to turn all setenv's to unsetenv but it doesn't seem to be working.根据modulefile 手册页,卸载模块命令应该将所有 setenv 转换为 unsetenv,但它似乎不起作用。 Does anyone know what I might be doing wrong here?有谁知道我在这里可能做错了什么?

More information:更多信息:

> module --version
VERSION=3.2.6
DATE=2007-02-14

AUTOLOADPATH=undef
BASEPREFIX="/usr/share"
BEGINENV=99
CACHE_AVAIL=undef
DEF_COLLATE_BY_NUMBER=undef
DOT_EXT=""
EVAL_ALIAS=1
HAS_BOURNE_FUNCS=1
HAS_BOURNE_ALIAS=1
HAS_TCLXLIBS=undef
HAS_X11LIBS=1
LMSPLIT_SIZE=undef
MODULEPATH="/company/tech/tools/modules/sites/$SITE/Linux/:/company/tech/tools/modules/projects"
MODULES_INIT_DIR="/usr/share/Modules/init"
PREFIX="/usr/share/Modules"
TCL_VERSION="8.4"
TCL_PATCH_LEVEL="8.4.19"
TMP_DIR="/tmp"
USE_FREE=undef
VERSION_MAGIC=1
VERSIONPATH=undef
WANTS_VERSIONING=0
WITH_DEBUG_INFO=undef

Hello World

> env | grep SHELL
SHELL=/bin/tcsh

For those unfamiliar with modulefiles (they do not seem to be that popular):对于那些不熟悉模块文件的人(它们似乎并不那么受欢迎):

  • modulefile is a simple bit of code that set or add entries to the PATH, MANPATH, or other environment variables modulefile 是一段简单的代码,用于设置或添加 PATH、MANPATH 或其他环境变量的条目
  • modulefiles hide the notion of different types of shells modulefiles 隐藏了不同类型的 shell 的概念
  • modulefiles are written in the Tool Command Language, Tcl and are interpreted by the modulecmd program via the module user interface模块文件用工具命令语言 Tcl 编写,并由 modulecmd 程序通过模块用户界面进行解释

Newer versions of Modules (>= 4.0) correctly unload this full path modulefile.较新版本的模块 (>= 4.0) 正确卸载此完整路径模块文件。

With older versions, the module unload command does not correctly match the full path modulefile passed on the command line with the currently loaded module.对于旧版本, module unload命令无法正确匹配命令行上传递的完整路径模块文件与当前加载的模块。 As a result no module is unloaded.结果没有模块被卸载。

Reproductible issue on older version (< 4.0):旧版本(< 4.0)的可重现问题:

$ module -V | grep ^VERSION=
VERSION=3.2.11
$ module load ~/modules/test
$ module list
Currently Loaded Modulefiles:
  1) /home/user/modules/test
$ module unload ~/modules/test
$ module list
Currently Loaded Modulefiles:
  1) /home/user/modules/test

As evil otto said, on older module version, short module name has to be used to unload this modulefile正如 evil otto 所说,在较旧的模块版本上,必须使用短模块名称来卸载此模块文件

$ module list
Currently Loaded Modulefiles:
  1) /home/user/modules/test
$ module unload test
$ module list
No Modulefiles Currently Loaded.

Expected behavior obtained on recent module version:在最近的模块版本上获得的预期行为:

$ module -V
Modules Release 4.1.3 (2018-06-18)
$ module load ~/modules/test
$ module list
Currently Loaded Modulefiles:
 1) /home/user/modules/test  
$ module unload ~/modules/test
$ module list
No Modulefiles Currently Loaded.

This is apparently working as intended: http://sourceforge.net/tracker/?func=detail&aid=2384340&group_id=15538&atid=115538这显然按预期工作: http://sourceforge.net/tracker/?func=detail&aid=2384340&group_id=15538&atid=115538

It seems you are expected to run module unload example_modulefile without giving it the full path to the module file.看来您应该运行module unload example_modulefile而不给它模块文件的完整路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM