Skip to main content
v2026.11,986 entries · CC-BY 4.0

Spack: HPC Package Manager Install and Use Guide

Install Spack, read its spec syntax, check installed packages with spack find and set up a reproducible environment, from the official documentation.

Written and maintained by CASRAI Editorial Board

Published

On this page

Spack is an open-source package manager for building and installing scientific software, widely used on high-performance computing (HPC) systems and Linux workstations. This guide is for lab and HPC staff who need to install Spack, check what is installed, and read the spec syntax that tells Spack exactly which version, compiler and options to use. Commands below follow the Spack documentation (spack.readthedocs.io, “Getting Started” and “Basic Usage”, read 2026-11-07).

What is Spack, and what is a Spack package?

Spack is a package manager: it lists software it knows how to build, builds it from source with the compiler and options you choose, and keeps several versions and configurations side by side. A package is one of those buildable items. You list them with spack list and inspect one with spack info, which shows its description, available versions and build options. (In this guide “Spack” always means this software.)

What makes it useful in research computing is that one package can exist in many configurations at once, for example the same MPI library built with two compilers. Spack names each configuration with a spec, covered below.

What Spack is used for in research

  • Installing scientific libraries and tools (for example hdf5, mpich and zlib appear in the official examples) from source, under your own account.
  • Keeping several builds of the same tool for different compilers or options.
  • Describing a set of packages once as an environment, so a collaborator can rebuild the same set. See reproducibility infrastructure for where this fits in a wider reproducibility practice.

How do I install Spack?

Spack is installed by cloning its repository and sourcing a setup script. The documentation gives:

git clone --depth=2 https://github.com/spack/spack.git
. spack/share/spack/setup-env.sh

Use setup-env.sh for bash, zsh or sh; source spack/share/spack/setup-env.csh for csh/tcsh; and . spack/share/spack/setup-env.fish for fish.

Most packages need a compiler. Run spack compiler find to search for compilers already on the machine and spack compiler list to see what was found. If none is found, the documentation says to install the prerequisites and repeat the search, or to register a build cache that provides a compiler as a binary. The documentation has “Prerequisites” and “Bootstrapping” pages for the details.

The download is the repository above, which is the project’s own source on GitHub. Our GitHub CLI guide covers the Git side if you are new to cloning repositories.

Step by step: install a package and use it

  1. spack list to see packages Spack can build.
  2. spack info hdf5 to read a package’s description, versions and build options.
  3. spack compiler find then spack compiler list to register and confirm compilers.
  4. spack spec -I mpich to preview, in the documentation’s words, “what will be reused and what will be built before you install.”
  5. spack install tcl to build and install (the documentation’s own example).
  6. spack load tcl to put it in your current shell, and spack unload tcl to remove it again.

Specs: how Spack names a configuration

The documentation states: “Spack calls the descriptor used to refer to a particular package configuration a spec.” Each part is added with a sigil. The examples below are taken from the documentation.

Part Syntax Documentation example
Version @ after the package name spack install [email protected]
Compiler % then compiler and version spack install mpich %[email protected]
Enable a build option (variant) +name spack find libdwarf +debug (only builds with the debug option)
Disable a variant -name spack install zlib -optimize
Constrain a dependency ^ spack install m4 ^[email protected]

How can I check installed packages using Spack?

Run spack find with no arguments. It lists installed packages, grouped by architecture and compiler, showing versions by default. Add flags to see more:

Flag What it shows
--long Hashes that distinguish configurations (spack find --long libdwarf)
--deps Dependencies of each result (spack find --deps libdwarf), each prefixed with ^
--paths Install locations
--format Custom output, e.g. spack find --format "{name}-{version}-{hash}"
--json Machine-readable output (spack find --json [email protected])
--loaded Packages currently loaded in your environment
--explicit / --implicit Packages installed directly versus pulled in as dependencies
--missing, --deprecated Missing dependencies of a spec; include deprecated packages

You can also pass a spec to filter, such as spack find [email protected]:. To see a package’s declared dependencies before installing, spack info mpich has a “Dependencies:” section.

Environments: a reproducible set of packages

The documentation says Spack provides “environments, and views, with which you can ‘activate’ a number of related packages all at once.” A minimal sequence from the documentation:

spack env create --with-view view --dir .
spack -e . add py-numpy
spack -e . concretize
spack -e . install
spack env activate .

Here add records the package in the environment, concretize resolves it to exact versions, compilers and dependencies, and install builds the result. For the same goal with another tool, see sharing a reproducible conda environment.

Removing packages and troubleshooting

  • No compiler found: run spack compiler find; if nothing is found, install prerequisites and search again, as above.
  • Not sure what a command will do: run spack spec -I <package> first.
  • Package not available in your shell: run spack load <package>, then check with spack find --loaded.
  • Several installs match a name: specify a version in the spec, or use --all with uninstall; spack find --long shows the hashes that tell them apart.
  • Uninstalling: spack uninstall <package> asks for confirmation; --dependents also removes packages that depend on it; --force removes it even though other installed packages may break.

FAQ

What is to spack?

In software searches it means using Spack, the package manager: to spack a package is to build and install it with spack install.

What is a Spack package?

A buildable item Spack knows about, listed by spack list and described by spack info.

How can I check installed packages using Spack?

Use spack find, with flags such as --long, --paths or --loaded.

How do I install Spack?

Clone https://github.com/spack/spack.git and source share/spack/setup-env.sh (or the csh or fish variant).

How do I use Spack day to day?

Run spack info, spack spec -I, spack install, spack load, then spack find to confirm.

Sources

Commands change between Spack releases; the documentation linked above is the authority for your installed version.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about Spack: HPC Package Manager Install and Use Guide

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →