We talked about having a "counter" for each setting, that knows that two
modules have loaded the same thing, so that unloading only happens if both
modules are unloaded.
however, that requires a pretty big change to the module command.
As a work around, you could make a unique symlinks to 'mydir', and then have
the modules use the symlink names instead of the real name. Then the
directories will appear to be unique. I'm not sure if this is a good idea...
The other idea is to never have modules use the same directory. Or if they do,
create a 'conflict' statement to prohibit both from being loaded at the same
time.
-Mark
Mark Lakata, Staff Engineer 1225 Charleston Road voice 650-567-5170
MIPS Technologies Mountain View CA 94043 fax 650-567-5002
On Tue, 29 Oct 2002, Jerry.Hershkowitz wrote:
> Modules-interest list,
>
> load-ing a module, then subsequently unload-ing the same module, does not
> necessarily return your environment back to where it was prior to the
> load. This is especially the case if several differnt modules use prepend-path
> or append-path to modify the same variable, and some of those modules add the
> same elements to the variable. Does anyone
> know a reasonable way to write modules, such that after performing
> a unload of a module, your environment will be back to where it was prior
> to originally loading that module?
>
> For example:
>
> --------------
> Module A:
>
> prepend-path PATH mydir
> setenv OTHER_VAR1 valueA
> ==============
>
> --------------
> Module B:
>
> prepend-path PATH mydir
> setenv OTHER_VAR2 valueB
> ==============
>
> We can see that both modules do different things (with OTHER_VAR1 and
> OTHER_VAR2), but both happen to add the same directory to the PATH variable.
>
> If we start with an undefined PATH environment variable (generally not the
> case, but it makes this example easier to illustrate, and the effect would
> be the same if PATH did have a previous value), and we perform:
>
> % module load A
>
> PATH would now have the value "mydir", and "module list" would show that
> module A is loaded. (Also, OTHER_VAR1 would have the value valueA.) Let's
> call this situation-1.
>
> Next, if we perform:
>
> % module load B
>
> since prepend-path is smart enough not to duplicate an element in environment
> variable, and since "mydir" is already an element in the PATH variable, mydir
> is NOT added again to PATH. PATH would now have just the value "mydir", and
> "module list" would show that both module A and module B are loaded.
> (Also, OTHER_VAR1 would have the value valueA, and OTHER_VAR2 would have
> the value valueB.) Let's call this situation-2
>
> Now, if we were to unload B, I'd expect that just A would be loaded, and
> I'd expect my environment to be the same as situation-1. But, if we
> try that, and perform:
>
> % module unload B
>
> the "prepend-path PATH mydir" in module B acts as a "remove-path PATH mydir",
> and therefore "mydir" is removed from PATH, and PATH now has nothing left
> in it (i.e. undefined). "module list" would show that module A is loaded.
> (Also OTHER_VAR2 would correctly be unset, leaving OTHER_VAR1 correctly set
> to valueA.) Let's call this situation-3.
>
> Thus, the problem. "module list" shows that module A is loaded. OTHER_VAR1
> has the correct setting that module A performed. But, despite module A
> being loaded, PATH does not have the value that module A applied to it.
> I would expect that our environment would appear identical to situation-1,
> but instead it is the different situation-3.
>
> Is there anything I should be doing in my modules such that after unloading
> module B, my environment would be back to where it was after having just
> A loaded? One thing I could think of is to include a "module update" command
> in all of my modules. But, if this needs to be added to all modules, maybe
> a module update should become a built-in part of "module unload".
> (Also, I've seen a strange problem related to "module update" that cause
> a TCL error when we use it sometimes, that I need to investigate further;
> perhaps the subject of a future posting.)
>
> What do other people do?
>
> Thanks,
>
> Jerry Hershkowitz
> Analog Devices
> Wilmington, MA
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Modules-interest mailing list
> Mod...@li...
> https://lists.sourceforge.net/lists/listinfo/modules-interest
>
|