Debian Codegraph @

doc/source/cookbook/unload-firstly-loaded.rst

raw
1 .. _unload-firstly-loaded:
2
3 Unload firstly loaded module matching name
4 ==========================================
5
6 Since Modules v4, unloading a given module name unloads lastly loaded module
7 matching this given name. On Modules v3 the module selected for the unload
8 was the firstly loaded not the lastly loaded. This recipe gives a way to
9 restore the behavior of the v3 version.
10
11 Implementation
12 --------------
13
14 Starting version v4.3, an :mconfig:`unload_match_order` configuration option
15 is introduced to control whether firstly loaded module or lastly loaded module
16 should be selected for the unload. To select firstly loaded module::
17
18 $ module config unload_match_order returnfirst
19
20 For older v4 versions, a site-specific configuration script is proposed to
21 select firstly loaded module matching name rather lastly loaded.
22
23 .. literalinclude:: ../../example/unload-firstly-loaded/siteconfig.tcl
24 :language: tcl
25 :caption: siteconfig.tcl
26 :lines: 15-20
27
28 **Compatible with Modules v4.2**
29
30 Installation (only for version older than v4.3)
31 -----------------------------------------------
32
33 Create site-specific configuration directory if it does not exist yet:
34
35 .. parsed-literal::
36
37 $ mkdir \ |etcdir|
38
39 Then copy there the site-specific configuration script of this recipe:
40
41 .. parsed-literal::
42
43 $ cp example/unload-firstly-loaded/siteconfig.tcl \ |etcdir|\ /
44
45 .. note::
46
47 Defined location for the site-specific configuration script may vary from
48 one installation to another. To determine the expected location for this
49 file on your setup, check the ``modulecmd.tcl`` script::
50
51 $ grep '^set g_siteconfig ' $MODULES_CMD
52
53 Usage example
54 -------------
55
56 With a bare ``foo/1`` modulefile:
57
58 .. literalinclude:: ../../example/unload-firstly-loaded/modulefiles/foo/1
59 :caption: foo/1
60
61 And a bare ``foo/2`` modulefile:
62
63 .. literalinclude:: ../../example/unload-firstly-loaded/modulefiles/foo/2
64 :caption: foo/2
65
66 Enable the modulepath where the example modulefiles are located::
67
68 $ module use example/unload-firstly-loaded/modulefiles
69
70 Load both ``foo`` modulefiles then attempt to unload ``foo`` name::
71
72 $ module load foo/1 foo/2
73 $ module list
74 Currently Loaded Modulefiles:
75 1) foo/1 2) foo/2
76 $ module unload foo
77 $ module list
78 Currently Loaded Modulefiles:
79 1) foo/2
80
81 .. vim:set tabstop=2 shiftwidth=2 expandtab autoindent: