diff --git a/src/mpsd_software_manager/mpsd_software.py b/src/mpsd_software_manager/mpsd_software.py index 871b4aa49099010f3aa9b146757b67be076e3e69..0d09055503c532abec9fe16ebdb1f58a95285788 100755 --- a/src/mpsd_software_manager/mpsd_software.py +++ b/src/mpsd_software_manager/mpsd_software.py @@ -1153,11 +1153,23 @@ def remove_environment(mpsd_release, root_dir, package_sets="NONE", force_remove def remove_spack_environment(spack_dir, environment_name): - """Remove spack environment.""" + """Remove spack environment including packages exclusive to it. + + First activate the environment, + then uninstall all packages exclusive to the environment, + then deactivate the environment, + and finally remove the environment. + Parameters + ---------- + spack_dir : pathlib.Path + A Path object representing the path to the spack directory. + environment_name : str + A string representing the name of the spack environment to remove. + """ logging.warning(f"Removing spack environment {environment_name}") spack_env = spack_dir / "share" / "spack" / "setup-env.sh" commands_to_execute = [ - f"export SPACK_DIR={spack_dir}", + f"export SPACK_DIR={spack_dir}", # need to set SPACK_DIR in dash and sh f". {spack_env}", f"spack env activate {environment_name}", f"for spec in $(spack -e {environment_name} find" # this line continues