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,mpichandzlibappear 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
spack listto see packages Spack can build.spack info hdf5to read a package’s description, versions and build options.spack compiler findthenspack compiler listto register and confirm compilers.spack spec -I mpichto preview, in the documentation’s words, “what will be reused and what will be built before you install.”spack install tclto build and install (the documentation’s own example).spack load tclto put it in your current shell, andspack unload tclto 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 withspack find --loaded. - Several installs match a name: specify a version in the spec, or use
--allwith uninstall;spack find --longshows the hashes that tell them apart. - Uninstalling:
spack uninstall <package>asks for confirmation;--dependentsalso removes packages that depend on it;--forceremoves 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
- Spack documentation, Getting Started, read 2026-11-07.
- Spack documentation, Basic Usage, read 2026-11-07.
Commands change between Spack releases; the documentation linked above is the authority for your installed version.







