Re: [Lmod-users] source_sh and LD_LIBRARY_PATH
A Lua based environment module system that reads TCL modulefiles.
Brought to you by:
rtmclay
From: Jakob S. <jak...@fa...> - 2025-05-13 16:20:57
|
Hi Robert, thanks for the quick reply. Good to know that the sequence below is not intended $ cat .modules/test1.sh export TEST="foo${TEST:+:}${TEST}" $ echo $TEST $ $LMOD_DIR/sh_to_modulefile .modules/test1.sh setenv("TEST","foo") $ export TEST="BAR" $ $LMOD_DIR/sh_to_modulefile .modules/test1.sh prepend_path("TEST","foo") $ cat .modules/test2.sh export LD_LIBRARY_PATH="foo${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}" $ echo $LD_LIBRARY_PATH $ $LMOD_DIR/sh_to_modulefile .modules/test2.sh setenv("LD_LIBRARY_PATH","foo") $ export LD_LIBRARY_PATH="bar" $ $LMOD_DIR/sh_to_modulefile .modules/test2.sh setenv("LD_LIBRARY_PATH","foo") I will open an issue shortly! Regards, Jakob On 5/13/25 6:07 PM, Robert McLay wrote: > Huh? There are no special variables w.r.t. > Source_sh/sh_to_modulefile. What you found is where sh_to_modulefile > says to wipe-out almost all env. vars. It keeps the value of > LD_LIBRARY_PATH before running the script. This is when > sh_to_modulefile is run with the --cleanEnv option. > > If a user has a value for any env. var. and then the script changes > it. Then it appends or prepends the value. If there is no previous > value, then Lmod uses setenv(). > > If you have a case where LD_LIBRARY_PATH has a value in the > environment (and not a local variable) and Lmod uses setenv instead of > append_path() or prepend_path() then that is a bug. Please submit a > bug report that shows this. > > Using setenv() when there is no previous value it not a bug. > > Best, > Robert > > ------------------------------------------------------------------------ > *From:* Jakob Stierhof <jak...@fa...> > *Sent:* Tuesday, May 13, 2025 8:22 AM > *To:* Lmo...@li... <Lmo...@li...> > *Subject:* [Lmod-users] source_sh and LD_LIBRARY_PATH > Dear Lmod users and developers, > > using the source_sh function or the sh_to_modulefile script to update an > environment based on a script that is meant to be sourced behaves as > expected except for LD_LIBRARY_PATH variable. When the script appends or > prepends to this variable, the source_sh function always treats this > variable as empty and therefore ends up in a 'setenv' instead of a > 'append_path' or 'prepend_path'. > > Regardless of it being a bad idea to have modules set LD_LIBRARY_PATH, > my expectation is that it is treated as any other environment variable, > which it clearly is not. > > The only place that I could identify where behavior might be modified is > in 'sh_to_modulefile', where LD_LIBRARY_PATH is in the the keepT table > with a 'keep' value. But my understanding is that source_sh is not using > sh_to_modulefile. > > Is this intentional behavior, and if so, is there a way to overwrite it > such that it is treated as a normal variable? > > I am running Lmod v8.7.60 > > I appreciate any hint! > > Kind regards, > Jakob > > > > > _______________________________________________ > Lmod-users mailing list > Lmo...@li... > https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Flmod-users&data=05%7C02%7C%7C04bd2bbe0f234ddc7ae308dd922c279b%7C31d7e2a5bdd8414e9e97bea998ebdfe1%7C0%7C0%7C638827440530443501%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=Kjd0w%2F4qIAxx%2BfIbsNfisiyDJkr4OzTDeDh9i8wN1JE%3D&reserved=0 > <https://lists.sourceforge.net/lists/listinfo/lmod-users> |