Install Spack on Ubuntu 20.04

Updated on January 22, 2021
Install Spack on Ubuntu 20.04 header image


Spack is a package manager to install scientific packages such as The Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST) or PNGwriter. This guide explains how to install Spack on an Ubuntu 20.04 Vultr cloud instance.


1. Install Dependencies

Install the build-essential.

$ sudo apt install build-essential

2. Clone Spack Repository

Clone the Spack repository to ~/.spack/Spack, or a directory of your choice.

$ git clone ~/.spack/Spack

3. Add Shell Support

To use Spack everywhere, add Spack to PATH:

$ . ~/.spack/Spack/share/spack/

To use the spack command every login, append that command to ~/.bash_profile:

$ echo '. ~/.spack/Spack/share/spack/' >> ~/.bash_profile

Then run source ~/.bash_profile or log out to make changes take effect.

4. Clear Environment

Because Spack builds and installs packages from their source code, it requires a clean environment. Make sure your PATH only has the things you need.

$ echo $PATH

5. Test Spack

Verify the Spack installation.

$ spack -V

Next Steps

You can install lots of powerful scientific packages via Spack, such as pngwriter.

$ spack install pngwriter
$ spack load pngwriter

More Resources