To make Spack use ~/.spack_test/ instead of the default ~/.spack/ directory, you need to set the SPACK_ROOT environment variable to point to your desired directory. Here’s how you can do it:
SPACK_ROOT Environment VariableAdd this line to your shell configuration file (e.g., ~/.bashrc, ~/.zshrc, or ~/.bash_profile):
bashexport SPACK_ROOT=$HOME/.spack_test
Then, reload your shell configuration:
bashsource ~/.bashrc # or the file you edited
Check that Spack is now using the new directory:
bashspack location --install-dir
This should return paths under ~/.spack_test/.
If you already have Spack installed in the default location, you may want to:
~/.spack/ to ~/.spack_test/.--prefix for a Single InstallIf you only want to change the install directory for a specific package, you can use:
bashspack install --prefix=~/.spack_test <package>
Note: If you are using Spack in a shared environment, ensure that the new directory has the correct permissions.