shell support: spack load
no longer needs modules (#14062)
Previously the `spack load` command was a wrapper around `module load`. This required some bootstrapping of modules to make `spack load` work properly. With this PR, the `spack` shell function handles the environment modifications necessary to add packages to your user environment. This removes the dependence on environment modules or lmod and removes the requirement to bootstrap spack (beyond using the setup-env scripts). Included in this PR is support for MacOS when using Apple's System Integrity Protection (SIP), which is enabled by default in modern MacOS versions. SIP clears the `LD_LIBRARY_PATH` and `DYLD_LIBRARY_PATH` variables on process startup for executables that live in `/usr` (but not '/usr/local', `/System`, `/bin`, and `/sbin` among other system locations. Spack cannot know the `LD_LIBRARY_PATH` of the calling process when executed using `/bin/sh` and `/usr/bin/python`. The `spack` shell function now manually forwards these two variables, if they are present, as `SPACK_<VAR>` and recovers those values on startup. - [x] spack load/unload no longer delegate to modules - [x] refactor user_environment modification calculations - [x] update documentation for spack load/unload Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
This commit is contained in:

committed by
Todd Gamblin

parent
5053dfa259
commit
c9e01ff9d7
@@ -104,20 +104,25 @@ contains "usage: spack module " spack -m module --help
|
||||
contains "usage: spack module " spack -m module
|
||||
|
||||
title 'Testing `spack load`'
|
||||
contains "module load $b_module" spack -m load b
|
||||
contains "export LD_LIBRARY_PATH=$(spack -m location -i b)/lib" spack -m load --only package --sh b
|
||||
succeeds spack -m load b
|
||||
fails spack -m load -l
|
||||
contains "module load -l --arg $b_module" spack -m load -l --arg b
|
||||
contains "module load $b_module $a_module" spack -m load -r a
|
||||
contains "module load $b_module $a_module" spack -m load --dependencies a
|
||||
# test a variable MacOS clears and one it doesn't for recursive loads
|
||||
contains "export LD_LIBRARY_PATH=$(spack -m location -i a)/lib:$(spack -m location -i b)/lib" spack -m load --sh a
|
||||
contains "export LIBRARY_PATH=$(spack -m location -i a)/lib:$(spack -m location -i b)/lib" spack -m load --sh a
|
||||
succeeds spack -m load --only dependencies a
|
||||
succeeds spack -m load --only package a
|
||||
fails spack -m load d
|
||||
contains "usage: spack load " spack -m load -h
|
||||
contains "usage: spack load " spack -m load -h d
|
||||
contains "usage: spack load " spack -m load --help
|
||||
|
||||
title 'Testing `spack unload`'
|
||||
contains "module unload $b_module" spack -m unload b
|
||||
spack -m load b a # setup
|
||||
succeeds spack -m unload b
|
||||
succeeds spack -m unload --all
|
||||
spack -m unload --all # cleanup
|
||||
fails spack -m unload -l
|
||||
contains "module unload -l --arg $b_module" spack -m unload -l --arg b
|
||||
fails spack -m unload d
|
||||
contains "usage: spack unload " spack -m unload -h
|
||||
contains "usage: spack unload " spack -m unload -h d
|
||||
|
Reference in New Issue
Block a user