Skip to content

Adding External Spack Packages

By default, Spack does not initially look for or grab any external versions of packages. This means that Spack favors building its own version of every package instead of trying to use what is already available. This section offers a few tips to help guide Spack into using more external packages. A more in-depth look at external packages in Spack can be found on there website, here

Basic Commands:

The first command one can use to help inform Spack is spack compiler find. This command looks for any compiler loaded in the environment and adds it to the list of compilers spack can try to use to build other packages. Without this, Spack will install its own compiler when the first package is installed. For system with modules, you will need to repeat the process of loading the compiler module and then doing spack compiler find for each compiler you are interested in telling Spack about.

The second command is spack external find. This command has Spack look for a set of specific packages Spack can attempt locate on its own. The packages Spack can find depends on the package, but generally limited to more common packages.

Package.yaml Files for Livermore Systems

The COMPASS Github organization has a separate repository that holds system-specific external packages and additional Spack package files for our various applications. For more details on how to setup your Spack to include these additional features, see the README in the COMPASS spack packages repository.

Manual Explanation:

Warning

These commands are for doing a manual setup of package files on a machine. For most new users, following the guide in the repository link above will be enough.

  1. If you are on a Livermore machine (not your personal machine):
    1. Create a ~/.profile file if does not exist already
    2. Add the line export SPACK_USER_CONFIG_PATH=$HOME/.spack/$CLUSTER. This tells Spack to look for package.yaml files in ~/.spack/[system_name]. $CLUSTER is provided by the OS on LLNL machines to identify the machine you are on.
    3. Restart your current shell and make sure echo $SPACK_USER_CONFIG_PATH reports the correct path! If it's blank, check if you have a .bash_profile in your top level directory. If so, you will need to move the export command from the .profile file to this file instead. For non-bash users, consult documentation to see which initialization files are loaded.
  2. Navigate to ~/.spack/[system_name]/packages.yaml. (Possible system names: tuolumne, tioga, dane) If the directory or the packages.yaml file do not exist, you'll need to create them first.
  3. Copy the contents of the appropriate packages.yaml file from the "COMPASS spack-packages" repository into the packages.yaml on the system you are using.
  4. Use Spack normally. Spack will now find packages already installed on the system and prefer those over installing duplicate libraries.