Tutorial setup

If you have not done the prior sections, you’ll need to start the docker image:

docker run -it ghcr.io/spack/tutorial:cineca23

and then set Spack up like this:

git clone --depth=100 --branch=releases/v0.19 https://github.com/spack/spack
. spack/share/spack/setup-env.sh
spack tutorial -y
spack bootstrap now
spack compiler find

See the Basic Installation Tutorial for full details on setup. For more help, join us in the #tutorial channel on Slack – get an invitation at spackpm.herokuapp.com

Mirrors and Binary Caches Tutorial

This tutorial will guide you through the process of setting up a source mirror with a binary cache. Source mirrors and binary caches are extremely useful when using spack on a machine without internet access. Source mirrors allow you to fetch source code from a directory on your filesystem instead of accessing the outside internet, and binary caches allow you to install pre-compiled binaries to your spack installation path. Together, these two features can speed up builds when using spack within a larger development team.

We will use the filesystem for the mirrors in this tutorial, but mirrors can also be setup on web servers or s3 buckets – any URL that curl can access can be setup as a Spack mirror.

By default, Spack comes configured with a source mirror in the cloud to increase download reliability. We’ve also already set up a mirror in this tutorial for binary caches. We can see these mirrors are configured

$ spack mirror list
tutorial	file:///mirror
spack-public	https://mirror.spack.io

Setting up a source cache mirror

When you run spack install, spack goes out to the internet to grab the source code to build your packages. This works fine on most clusters, but what do you do if the cluster in question doesn’t have access to the outside internet? This could happen for a variety of reasons. Maybe you’re building on a compute node that isn’t connected to the greater internet, or maybe even the whole cluster has been isolated from the internet.

Spack has an easy answer to this – setting up a source mirror. When you use a source mirror, spack checks the mirror for the source code before going to the outside internet.

Building a source mirror is easy. Let’s start with the same simple environment. First, let’s build our software on a computer with external internet access.

$ cd ~
$ mkdir cache-env
$ cd cache-env
$ spack env create -d .
==> Created environment in /home/spack/cache-env
==> You can activate this environment with:
==>   spack env activate /home/spack/cache-env
$ spacktivate .
$ # for now, disable fortran support in all packages
$ spack config add "packages:all:variants: ~fortran"
$ spack add macsio+scr
==> Adding macsio+scr to environment /home/spack/cache-env
$ spack install
==> Concretized macsio+scr
[+]  pbkwpsk  macsio@1.1%gcc@7.5.0~exodus~hdf5~ipo+mpi~pdb+scr+silo~szip~typhonio~zfp~zlib build_system=cmake build_type=RelWithDebInfo patches=59479b9 arch=linux-ubuntu18.04-x86_64
[+]  stszbns	  ^cmake@3.24.3%gcc@7.5.0~doc+ncurses+ownlibs~qt build_system=generic build_type=Release arch=linux-ubuntu18.04-x86_64
[+]  zcuawli	      ^ncurses@6.3%gcc@7.5.0~symlinks+termlib abi=none build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  yr4z2pt	      ^openssl@1.1.1s%gcc@7.5.0~docs~shared build_system=generic certs=mozilla arch=linux-ubuntu18.04-x86_64
[+]  aurd37j		  ^ca-certificates-mozilla@2022-10-11%gcc@7.5.0 build_system=generic arch=linux-ubuntu18.04-x86_64
[+]  4g3jur3	  ^json-cwx@0.12%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  btoteei	      ^autoconf@2.69%gcc@7.5.0 build_system=autotools patches=35c4492,7793209,a49dd5b arch=linux-ubuntu18.04-x86_64
[+]  rxjqnjw	      ^automake@1.16.5%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  bdxu4wn	      ^libtool@2.4.7%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  z7d5q4f	      ^m4@1.4.19%gcc@7.5.0+sigsegv build_system=autotools patches=9dc5fbd,bfdffa7 arch=linux-ubuntu18.04-x86_64
[+]  c3uhkcj		  ^diffutils@3.8%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  ltvovvv		      ^libiconv@1.16%gcc@7.5.0 build_system=autotools libs=shared,static arch=linux-ubuntu18.04-x86_64
[+]  e262sf6		  ^libsigsegv@2.13%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  mfxvu5f	  ^openmpi@4.1.4%gcc@7.5.0~atomics~cuda~cxx~cxx_exceptions~gpfs~internal-hwloc~java~legacylaunchers~lustre~memchecker+romio+rsh~singularity+static+vt+wrapper-rpath build_system=autotools fabrics=none schedulers=none arch=linux-ubuntu18.04-x86_64
[+]  5yywrk2	      ^hwloc@2.8.0%gcc@7.5.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml~oneapi-level-zero~opencl+pci~rocm build_system=autotools libs=shared,static arch=linux-ubuntu18.04-x86_64
[+]  p7f5n6q		  ^libpciaccess@0.16%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  ao5w53r		      ^util-macros@1.19.3%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  4aq5aj2		  ^libxml2@2.10.1%gcc@7.5.0~python build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  nrwxyth		      ^xz@5.2.7%gcc@7.5.0~pic build_system=autotools libs=shared,static arch=linux-ubuntu18.04-x86_64
[+]  qbwqmk6	      ^numactl@2.0.14%gcc@7.5.0 build_system=autotools patches=4e1d78c,62fc8a8,ff37630 arch=linux-ubuntu18.04-x86_64
[+]  xevso22	      ^openssh@9.1p1%gcc@7.5.0+gssapi build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  y6ek4vz		  ^krb5@1.19.3%gcc@7.5.0+shared build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  wobmzgv		      ^bison@3.8.2%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  hj6szik		      ^gettext@0.21.1%gcc@7.5.0+bzip2+curses+git~libunistring+libxml2+tar+xz build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  kawegoy			  ^tar@1.34%gcc@7.5.0 build_system=autotools zip=pigz arch=linux-ubuntu18.04-x86_64
[+]  wod35ny			      ^pigz@2.7%gcc@7.5.0 build_system=makefile arch=linux-ubuntu18.04-x86_64
[+]  fprmzmo			      ^zstd@1.5.2%gcc@7.5.0+programs build_system=makefile compression=none libs=shared,static arch=linux-ubuntu18.04-x86_64
[+]  6pzeykr		  ^libedit@3.1-20210216%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  eydiwim	      ^perl@5.36.0%gcc@7.5.0+cpanm+shared+threads build_system=generic arch=linux-ubuntu18.04-x86_64
[+]  53fb72w		  ^berkeley-db@18.1.40%gcc@7.5.0+cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=linux-ubuntu18.04-x86_64
[+]  cxcreln		  ^bzip2@1.0.8%gcc@7.5.0~debug~pic+shared build_system=generic arch=linux-ubuntu18.04-x86_64
[+]  cpmynty		  ^gdbm@1.23%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  k2lfw6f	      ^pkgconf@1.8.0%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  76ul6un	      ^pmix@4.1.2%gcc@7.5.0~docs+pmi_backwards_compatibility~restful build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  nblr6w4		  ^libevent@2.1.12%gcc@7.5.0+openssl build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  2hfr5rb	      ^zlib@1.2.13%gcc@7.5.0+optimize+pic+shared build_system=makefile arch=linux-ubuntu18.04-x86_64
[+]  nwawfek	  ^scr@2.0.0%gcc@7.5.0+dtcmp~fortran~ipo+libyogrt async_api=NONE build_system=cmake build_type=RelWithDebInfo cache_base=/dev/shm cntl_base=/dev/shm copy_config=none file_lock=FLOCK resource_manager=SLURM scr_config=scr.conf arch=linux-ubuntu18.04-x86_64
[+]  jpa7i2q	      ^dtcmp@1.1.4%gcc@7.5.0+shared build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  it5zkjf		  ^lwgrp@1.0.5%gcc@7.5.0+shared build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  kv6hvaf	      ^libyogrt@1.27%gcc@7.5.0~static build_system=autotools scheduler=slurm arch=linux-ubuntu18.04-x86_64
[+]  p2tmqkb		  ^slurm@21-08-8-2%gcc@7.5.0~gtk~hdf5~hwloc~mariadb~pmix+readline~restd build_system=autotools sysconfdir=PREFIX/etc arch=linux-ubuntu18.04-x86_64
[+]  wc2juod		      ^curl@7.85.0%gcc@7.5.0~gssapi~ldap~libidn2~librtmp~libssh~libssh2~nghttp2 build_system=autotools libs=shared,static tls=openssl arch=linux-ubuntu18.04-x86_64
[+]  z5u7d3q		      ^glib@2.74.1%gcc@7.5.0~libmount build_system=generic tracing=none arch=linux-ubuntu18.04-x86_64
[+]  qzq4b7h			  ^libffi@3.4.2%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  z43z3fa			  ^meson@0.63.3%gcc@7.5.0 build_system=python_pip patches=aa6c50d arch=linux-ubuntu18.04-x86_64
[+]  bfqiunh			      ^py-pip@22.2.2%gcc@7.5.0 build_system=generic arch=linux-ubuntu18.04-x86_64
[+]  xik3yv6			      ^py-setuptools@65.5.0%gcc@7.5.0 build_system=generic arch=linux-ubuntu18.04-x86_64
[+]  4yhmu3f			      ^py-wheel@0.37.1%gcc@7.5.0 build_system=generic arch=linux-ubuntu18.04-x86_64
[+]  ml4nwp3			  ^ninja@1.11.1%gcc@7.5.0 build_system=generic arch=linux-ubuntu18.04-x86_64
[+]  gtbod2d			  ^pcre2@10.39%gcc@7.5.0~jit+multibyte build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  cyf55fe			  ^python@3.10.8%gcc@7.5.0+bz2+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tix~tkinter~ucs4+uuid+zlib build_system=generic patches=0d98e93,7d40923,f2fd060 arch=linux-ubuntu18.04-x86_64
[+]  j5k5nzg			      ^expat@2.4.8%gcc@7.5.0+libbsd build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  qieib3t				  ^libbsd@0.11.5%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  miq3rrs				      ^libmd@1.0.4%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  vmf7qax			      ^sqlite@3.39.4%gcc@7.5.0+column_metadata+dynamic_extensions+fts~functions+rtree build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  eayyoxj			      ^util-linux-uuid@2.38.1%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  wwi7hmc		      ^json-c@0.16%gcc@7.5.0~ipo build_system=cmake build_type=RelWithDebInfo arch=linux-ubuntu18.04-x86_64
[+]  grcwjnc		      ^lz4@1.9.4%gcc@7.5.0 build_system=makefile libs=shared,static arch=linux-ubuntu18.04-x86_64
[+]  llrb4kh		      ^munge@0.5.15%gcc@7.5.0 build_system=autotools localstatedir=PREFIX/var arch=linux-ubuntu18.04-x86_64
[+]  xnc35ij			  ^libgcrypt@1.10.1%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  m6alhez			      ^libgpg-error@1.46%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  nybpksa				  ^gawk@5.1.1%gcc@7.5.0~nls build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  iowhen4				      ^gmp@6.2.1%gcc@7.5.0 build_system=autotools libs=shared,static arch=linux-ubuntu18.04-x86_64
[+]  h4tcmq3				      ^mpfr@4.1.0%gcc@7.5.0 build_system=autotools libs=shared,static arch=linux-ubuntu18.04-x86_64
[+]  hdyi7fu					  ^texinfo@6.5%gcc@7.5.0 build_system=autotools patches=12f6edb,1732115 arch=linux-ubuntu18.04-x86_64
[+]  2uj3346	      ^pdsh@2.31%gcc@7.5.0+ssh+static_modules build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  v2i3mr5	  ^silo@4.10.2%gcc@7.5.0~fortran+fpzip+hdf5+hzip+mpi+pic+shared~silex build_system=autotools patches=3a1e831,7b5a1dc,eb2a3a0,fa050e0 arch=linux-ubuntu18.04-x86_64
[+]  rolnbco	      ^autoconf-archive@2022.02.11%gcc@7.5.0 build_system=autotools patches=139214f arch=linux-ubuntu18.04-x86_64
[+]  xfftbwl	      ^hdf5@1.12.2%gcc@7.5.0~cxx~fortran~hl~ipo~java+mpi+shared~szip~threadsafe+tools api=default build_system=cmake build_type=RelWithDebInfo arch=linux-ubuntu18.04-x86_64
[+]  kgyvtw5	      ^readline@8.1.2%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64

==> Installing environment /home/spack/cache-env
==> All of the packages are already installed

Once we’ve created and installed this environment, we can easily upload source code needed to reproduce this build to a mirror. The following command both creates the mirror and uploads the source code for the scr package included in our environment. The -d flag (short for --directory) tells spack where to place the mirrored source code files.

$ spack mirror create -d ~/mirror scr
==> Concretizing input specs
==> Adding package scr@2.0.0 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/47/471978ae0afb56a20847d3989b994fbd680d1dea21e77a5a46a964b6e3deed6b.tar.gz
==> Summary for mirror in /home/spack/mirror
==> Archive stats:
    0	 already present
    1	 added
    0	 failed to fetch.

We can configure spack to use this source mirror by adding a few lines to your spack.yaml file.

$ spack mirror add mymirror ~/mirror

Manually uploading every package in an environment can be tedious. Luckily, when run within an environment, spack mirror create with the --all flag will upload every source used to build the current environment to the specified directory.

$ spack mirror create -d ~/mirror --all
==> Adding package autoconf@2.69 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/95/954bd69b391edc12d6a4a51a2dd1476543da5c6bbf05a95b59dc0dd6fd4c2969.tar.gz
==> Fetching https://mirror.spack.io/_source-cache/archive/ea/eaa3f69d927a853313a0b06e2117c51adab6377a2278549b05abc5df93643e16
==> Fetching https://mirror.spack.io/_source-cache/archive/77/7793209b33013dc0f81208718c68440c5aae80e7a1c4b8d336e382525af791a7
==> Fetching https://mirror.spack.io/_source-cache/archive/35/35c449281546376449766f92d49fc121ca50e330e60fefcfc9be2af3253082c2
==> Fetching https://mirror.spack.io/_source-cache/archive/a4/a49dd5bac3b62daa0ff688ab4d508d71dbd2f4f8d7e2a02321926346161bf3ee
==> Adding package autoconf-archive@2022.02.11 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/78/78a61b611e2eeb55a89e0398e0ce387bcaf57fe2dd53c6fe427130f777ad1e8c.tar.xz
==> Fetching https://mirror.spack.io/_source-cache/archive/13/139214f5104f699f868dc87a14378e1e694a3c2539efa0de6f878024f3d7c66d
==> Adding package automake@1.16.5 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/07/07bd24ad08a64bc17250ce09ec56e921d6343903943e99ccf63bbf0705e34605.tar.gz
==> Adding package berkeley-db@18.1.40 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/0c/0cecb2ef0c67b166de93732769abdeba0555086d51de1090df325e18ee8da9c8.tar.gz
==> Adding package bison@3.8.2 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/06/06c9e13bdf7eb24d4ceb6b59205a4f67c2c7e7213119644430fe82fbd14a0abb.tar.gz
==> Adding package bzip2@1.0.8 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/ab/ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269.tar.gz
==> Adding package ca-certificates-mozilla@2022-10-11 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/2c/2cff03f9efdaf52626bd1b451d700605dc1ea000c5da56bd0fc59f8f43071040
==> Adding package cmake@3.24.3 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/b5/b53aa10fa82bff84ccdb59065927b72d3bee49f4d86261249fc0984b3b367291.tar.gz
==> Adding package curl@7.85.0 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/21/21a7e83628ee96164ac2b36ff6bf99d467c7b0b621c1f7e317d8f0d96011539c.tar.bz2
==> Adding package diffutils@3.8 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/a6/a6bdd7d1b31266d11c4f4de6c1b748d4607ab0231af5188fc2533d0ae2438fec.tar.xz
==> Adding package dtcmp@1.1.4 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/dd/dd83d8cecd68e13b78b68e88675cc5847cde06742b7740e140b98f4a08127dd3.tar.gz
==> Adding package expat@2.4.8 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/a2/a247a7f6bbb21cf2ca81ea4cbb916bfb9717ca523631675f99b3d4a5678dcd16.tar.bz2
==> Adding package gawk@5.1.1 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/d8/d87629386e894bbea11a5e00515fc909dc9b7249529dad9e6a3a2c77085f7ea2.tar.xz
==> Adding package gdbm@1.23 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/74/74b1081d21fff13ae4bd7c16e5d6e504a4c26f7cde1dca0d963a484174bbcacd.tar.gz
==> Adding package gettext@0.21.1 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/50/50dbc8f39797950aa2c98e939947c527e5ac9ebd2c1b99dd7b06ba33a6767ae6.tar.xz
==> Adding package glib@2.74.1 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/0a/0ab981618d1db47845e56417b0d7c123f81a3427b2b9c93f5a46ff5bbb964964.tar.xz
==> Adding package gmp@6.2.1 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/ea/eae9326beb4158c386e39a356818031bd28f3124cf915f8c5b1dc4c7a36b4d7c.tar.bz2
==> Adding package hdf5@1.12.2 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/2a/2a89af03d56ce7502dcae18232c241281ad1773561ec00c0f0e8ee2463910f14.tar.gz
==> Fetching https://mirror.spack.io/_source-cache/archive/57/57cee5ff1992b4098eda079815c36fc2da9b10e00a9056df054f2384c4fc7523
==> Adding package hwloc@2.8.0 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/20/20b2bd4df436827d8e50f7afeafb6f967259f2fb374ce7330244f8d0ed2dde6f.tar.gz
==> Adding package json-c@0.16 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/8e/8e45ac8f96ec7791eaf3bb7ee50e9c2100bbbc87b8d0f1d030c5ba8a0288d96b.tar.gz
==> Adding package json-cwx@0.12 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/3b/3bfae1f23eacba53ee130dbd1a6acf617af4627a9b4e4581d64b20a99b4e2b60.tar.gz
==> Adding package krb5@1.19.3 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/56/56d04863cfddc9d9eb7af17556e043e3537d41c6e545610778676cf551b9dcd0.tar.gz
==> Adding package libbsd@0.11.5 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/1a/1a9c952525635c1bb6770cb22e969b938d8e6a9d7912362b98ee8370599b0efd.tar.xz
==> Adding package libedit@3.1-20210216 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/22/2283f741d2aab935c8c52c04b57bf952d02c2c02e651172f8ac811f77b1fc77a.tar.gz
==> Adding package libevent@2.1.12 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/92/92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb.tar.gz
==> Adding package libffi@3.4.2 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/54/540fb721619a6aba3bdeef7d940d8e9e0e6d2c193595bc243241b77ff9e93620.tar.gz
==> Adding package libgcrypt@1.10.1 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/ef/ef14ae546b0084cd84259f61a55e07a38c3b53afc0f546bffcef2f01baffe9de.tar.bz2
==> Adding package libgpg-error@1.46 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/b7/b7e11a64246bbe5ef37748de43b245abd72cfcd53c9ae5e7fc5ca59f1c81268d.tar.bz2
==> Adding package libiconv@1.16 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/e6/e6a1b1b589654277ee790cce3734f07876ac4ccfaecbee8afa0b649cf529cc04.tar.gz
==> Adding package libmd@1.0.4 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/f5/f51c921042e34beddeded4b75557656559cf5b1f2448033b4c1eec11c07e530f.tar.xz
==> Adding package libpciaccess@0.16 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/84/84413553994aef0070cf420050aa5c0a51b1956b404920e21b81e96db6a61a27.tar.gz
==> Adding package libsigsegv@2.13 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/be/be78ee4176b05f7c75ff03298d84874db90f4b6c9d5503f0da1226b3a3c48119.tar.gz
==> Adding package libtool@2.4.7 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/04/04e96c2404ea70c590c546eba4202a4e12722c640016c12b9b2f1ce3d481e9a8.tar.gz
==> Adding package libxml2@2.10.1 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/21/21a9e13cc7c4717a6c36268d0924f92c3f67a1ece6b7ff9d588958a6db9fb9d8.tar.xz
==> Fetching https://mirror.spack.io/_source-cache/archive/96/96151685cec997e1f9f3387e3626d61e6284d4d6e66e0e440c209286c03e9cc7.tar.gz
==> Fetching https://mirror.spack.io/_source-cache/archive/3e/3e06d42596b105839648070a5921157fe284b932289ffdbfa304ddc3457e5637
==> Adding package libyogrt@1.27 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/c5/c57ce60770b61aa20bc83fe34ff52b5e444964338df3786f282d0d9bcdd26138.tar.gz
==> Adding package lwgrp@1.0.5 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/16/16b579e13b8a5218f4fe1b8715f6aafb09133a0cefbcd6b2eaf73802955dee6b.tar.gz
==> Adding package lz4@1.9.4 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/0b/0b0e3aa07c8c063ddf40b082bdf7e37a1562bda40a0ff5272957f3e987e0e54b.tar.gz
==> Adding package m4@1.4.19 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/3b/3be4a26d825ffdfda52a56fc43246456989a3630093cced3fbddf4771ee58a70.tar.gz
==> Fetching https://mirror.spack.io/_source-cache/archive/fc/fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8
==> Adding package macsio@1.1 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/a8/a86249b0f10647c0b631773db69568388094605ec1a0af149d9e61e95e6961ec.tar.gz
==> Adding package meson@0.63.3 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/7c/7c516c2099b762203e8a0a22412aa465b7396e6f9b1ab728bad6e6db44dc2659.tar.gz
==> Adding package mpfr@4.1.0 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/fe/feced2d430dd5a97805fa289fed3fc8ff2b094c02d05287fd6133e7f1f0ec926.tar.bz2
==> Fetching https://mirror.spack.io/_source-cache/archive/3f/3f80b836948aa96f8d1cb9cc7f3f55973f19285482a96f9a4e1623d460bcccf0
==> Fetching https://mirror.spack.io/_source-cache/archive/52/5230aab653fa8675fc05b5bdd3890e071e8df49a92a9d58c4284024affd27739
==> Fetching https://mirror.spack.io/_source-cache/archive/7a/7a6dd71bcda4803d6b89612706a17b8816e1acd5dd9bf1bec29cf748f3b60008
==> Fetching https://mirror.spack.io/_source-cache/archive/1a/1ae14fb3a54ae8e0faed20801970255b279eee9e5ac624891ab5d29727f0bc04
==> Fetching https://mirror.spack.io/_source-cache/archive/11/113705d5333ef0d0ad3eb136a85404ba6bd1cc524dece5ce902c536aa2e29903
==> Fetching https://mirror.spack.io/_source-cache/archive/41/4152a780b3cc6e9643283e59093b43460196d0fea9302d8c93b2496f6679f4e4
==> Fetching https://mirror.spack.io/_source-cache/archive/1b/1b9fdb515efb09a506a01e1eb307b1464455f5ca63d6c193db3a3da371ab3220
==> Adding package munge@0.5.15 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/3f/3f979df117a34c74db8fe2835521044bdeb08e3b7d0f168ca97c3547f51da9ba.tar.xz
==> Adding package ncurses@6.3 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/97/97fc51ac2b085d4cde31ef4d2c3122c21abc217e9090a43a30fc5ec21684e059.tar.gz
==> Adding package ninja@1.11.1 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/31/31747ae633213f1eda3842686f83c2aa1412e0f5691d1c14dbbcc67fe7400cea.tar.gz
==> Adding package numactl@2.0.14 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/1e/1ee27abd07ff6ba140aaf9bc6379b37825e54496e01d6f7343330cf1a4487035.tar.gz
==> Adding package openmpi@4.1.4 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/92/92912e175fd1234368c8730c03f4996fe5942e7479bb1d10059405e7f2b3930d.tar.bz2
==> Adding package openssh@9.1p1 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/19/19f85009c7e3e23787f0236fbb1578392ab4d4bf9f8ec5fe6bc1cd7e8bfdd288.tar.gz
==> Adding package openssl@1.1.1s to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/c5/c5ac01e760ee6ff0dab61d6b2bbd30146724d063eb322180c6f18a6f74e4b6aa.tar.gz
==> Fetching https://mirror.spack.io/_source-cache/archive/3f/3fdcf2d1e47c34f3a012f23306322c5a35cad55b180c9b6fb34537b55884645c
==> Adding package pcre2@10.39 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/0f/0f03caf57f81d9ff362ac28cd389c055ec2bf0678d277349a1a4bee00ad6d440.tar.bz2
==> Adding package pdsh@2.31 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/0e/0ee066ce395703285cf4f6cf00b54b7097d12457a4b1c146bc6f33d8ba73caa7.tar.gz
==> Adding package perl@5.36.0 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/e2/e26085af8ac396f62add8a533c3a0ea8c8497d836f0689347ac5abd7b7a4e00a.tar.gz
==> Fetching https://mirror.spack.io/_source-cache/archive/9d/9da50e155df72bce55cb69f51f1dbb4b62d23740fb99f6178bb27f22ebdf8a46.tar.gz
==> Fetching https://mirror.spack.io/_source-cache/archive/8c/8cf4302ca8b480c60ccdcaa29ec53d9d50a71d4baf469ac8c6fca00ca31e58a2
==> Fetching https://mirror.spack.io/_source-cache/archive/3b/3bbd7d6f9933d80b9571533867b444c6f8f5a1ba0575bfba1fba4db9d885a71a
==> Fetching https://mirror.spack.io/_source-cache/archive/0e/0eac10ed90aeb0459ad8851f88081d439a4e41978e586ec743069e8b059370ac
==> Adding package pigz@2.7 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/d2/d2045087dae5e9482158f1f1c0f21c7d3de6f7cdc7cc5848bdabda544e69aa58.tar.gz
==> Adding package pkgconf@1.8.0 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/ef/ef9c7e61822b7cb8356e6e9e1dca58d9556f3200d78acab35e4347e9d4c2bbaf.tar.xz
==> Adding package pmix@4.1.2 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/67/670d3a02b39fb2126fe8084174cf03c484e027b5921b5c98a851108134e2597a.tar.bz2
==> Adding package py-pip@22.2.2 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/b6/b61a374b5bc40a6e982426aede40c9b5a08ff20e640f5b56977f4f91fed1e39a
==> Adding package py-setuptools@65.5.0 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/f6/f62ea9da9ed6289bfe868cd6845968a2c854d1427f8548d52cae02a42b4f0356
==> Adding package py-wheel@0.37.1 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/4b/4bdcd7d840138086126cd09254dc6195fb4fc6f01c050a1d7236f2630db1d22a
==> Adding package python@3.10.8 to mirror
==> Fetching https://www.python.org/ftp/python/3.10.8/Python-3.10.8.tgz
==> Adding package readline@8.1.2 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/75/7589a2381a8419e68654a47623ce7dfcb756815c8fee726b98f90bf668af7bc6.tar.gz
==> Adding package scr@2.0.0 to mirror
==> Adding package silo@4.10.2 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/3a/3af87e5f0608a69849c00eb7c73b11f8422fa36903dd14610584506e7f68e638.tgz
==> Adding package slurm@21-08-8-2 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/87/876d7dfa716990d7e579cfb9c6ffc123258e03a1450e993ade596d2ee90afcdd.tar.gz
==> Adding package sqlite@3.39.4 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/f3/f31d445b48e67e284cf206717cc170ab63cbe4fd7f79a82793b772285e78fdbb.tar.gz
==> Adding package tar@1.34 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/03/03d908cf5768cfe6b7ad588c921c6ed21acabfb2b79b788d1330453507647aed.tar.gz
==> Adding package texinfo@6.5 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/d3/d34272e4042c46186ddcd66bd5d980c0ca14ff734444686ccf8131f6ec8b1427.tar.gz
==> Adding package util-linux-uuid@2.38.1 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/08/0820eb8eea90408047e3715424bc6be771417047f683950fecb4bdd2e2cbbc6e.tar.gz
==> Adding package util-macros@1.19.3 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/0f/0f812e6e9d2786ba8f54b960ee563c0663ddbe2434bf24ff193f5feab1f31971.tar.bz2
==> Adding package xz@5.2.7 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/b6/b65f1d0c2708e57716f4dd2216989a73847ac6fdb4168ffceb155767e22b834b.tar.bz2
==> Adding package zlib@1.2.13 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/b3/b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30.tar.gz
==> Adding package zstd@1.5.2 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/f7/f7de13462f7a82c29ab865820149e778cbfe01087b3a55b5332707abf9db4a6e.tar.gz
==> Summary for mirror in /home/spack/mirror
==> Archive stats:
    1	 already present
    69	 added
    0	 failed to fetch.

This directory can be shared between users on a shared filesystem and protected with typical unix file permissions. If you’re making a spack mirror on a shared filesystem, remember to fix the file permissions every time you update the mirror, or update your umask settings so any new files you create have the appropriate permissions. Here you would replace the word spack to the appropriate unix group.

$ umask 750
$ chmod -R g+rs ~/mirror
$ chgrp -R spack ~/mirror

As long as spack can read from the mirror directory, spack will attempt to read source packages from the mirror instead of accessing the internet. This can be a huge boon for computers that can’t access the external internet but can access a shared filesystem. If you need to use spack on a system that is isolated from the external internet, you must bundle the whole spack mirror directory and unbundle it on the isolated system. From there, you follow the same steps to use the spack mirror as you would on any computer that can’t access the external internet.

If you need to add more sources to the mirror, you can re-run the command you used to create the mirror. For example, assume we want to add unzip to our environment.

$ spack add unzip
==> Adding unzip to environment /home/spack/cache-env
$ spack install
==> Concretized macsio+scr
[+]  pbkwpsk  macsio@1.1%gcc@7.5.0~exodus~hdf5~ipo+mpi~pdb+scr+silo~szip~typhonio~zfp~zlib build_system=cmake build_type=RelWithDebInfo patches=59479b9 arch=linux-ubuntu18.04-x86_64
[+]  stszbns	  ^cmake@3.24.3%gcc@7.5.0~doc+ncurses+ownlibs~qt build_system=generic build_type=Release arch=linux-ubuntu18.04-x86_64
[+]  zcuawli	      ^ncurses@6.3%gcc@7.5.0~symlinks+termlib abi=none build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  yr4z2pt	      ^openssl@1.1.1s%gcc@7.5.0~docs~shared build_system=generic certs=mozilla arch=linux-ubuntu18.04-x86_64
[+]  aurd37j		  ^ca-certificates-mozilla@2022-10-11%gcc@7.5.0 build_system=generic arch=linux-ubuntu18.04-x86_64
[+]  4g3jur3	  ^json-cwx@0.12%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  btoteei	      ^autoconf@2.69%gcc@7.5.0 build_system=autotools patches=35c4492,7793209,a49dd5b arch=linux-ubuntu18.04-x86_64
[+]  rxjqnjw	      ^automake@1.16.5%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  bdxu4wn	      ^libtool@2.4.7%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  z7d5q4f	      ^m4@1.4.19%gcc@7.5.0+sigsegv build_system=autotools patches=9dc5fbd,bfdffa7 arch=linux-ubuntu18.04-x86_64
[+]  c3uhkcj		  ^diffutils@3.8%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  ltvovvv		      ^libiconv@1.16%gcc@7.5.0 build_system=autotools libs=shared,static arch=linux-ubuntu18.04-x86_64
[+]  e262sf6		  ^libsigsegv@2.13%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  mfxvu5f	  ^openmpi@4.1.4%gcc@7.5.0~atomics~cuda~cxx~cxx_exceptions~gpfs~internal-hwloc~java~legacylaunchers~lustre~memchecker+romio+rsh~singularity+static+vt+wrapper-rpath build_system=autotools fabrics=none schedulers=none arch=linux-ubuntu18.04-x86_64
[+]  5yywrk2	      ^hwloc@2.8.0%gcc@7.5.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml~oneapi-level-zero~opencl+pci~rocm build_system=autotools libs=shared,static arch=linux-ubuntu18.04-x86_64
[+]  p7f5n6q		  ^libpciaccess@0.16%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  ao5w53r		      ^util-macros@1.19.3%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  4aq5aj2		  ^libxml2@2.10.1%gcc@7.5.0~python build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  nrwxyth		      ^xz@5.2.7%gcc@7.5.0~pic build_system=autotools libs=shared,static arch=linux-ubuntu18.04-x86_64
[+]  qbwqmk6	      ^numactl@2.0.14%gcc@7.5.0 build_system=autotools patches=4e1d78c,62fc8a8,ff37630 arch=linux-ubuntu18.04-x86_64
[+]  xevso22	      ^openssh@9.1p1%gcc@7.5.0+gssapi build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  y6ek4vz		  ^krb5@1.19.3%gcc@7.5.0+shared build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  wobmzgv		      ^bison@3.8.2%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  hj6szik		      ^gettext@0.21.1%gcc@7.5.0+bzip2+curses+git~libunistring+libxml2+tar+xz build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  kawegoy			  ^tar@1.34%gcc@7.5.0 build_system=autotools zip=pigz arch=linux-ubuntu18.04-x86_64
[+]  wod35ny			      ^pigz@2.7%gcc@7.5.0 build_system=makefile arch=linux-ubuntu18.04-x86_64
[+]  fprmzmo			      ^zstd@1.5.2%gcc@7.5.0+programs build_system=makefile compression=none libs=shared,static arch=linux-ubuntu18.04-x86_64
[+]  6pzeykr		  ^libedit@3.1-20210216%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  eydiwim	      ^perl@5.36.0%gcc@7.5.0+cpanm+shared+threads build_system=generic arch=linux-ubuntu18.04-x86_64
[+]  53fb72w		  ^berkeley-db@18.1.40%gcc@7.5.0+cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=linux-ubuntu18.04-x86_64
[+]  cxcreln		  ^bzip2@1.0.8%gcc@7.5.0~debug~pic+shared build_system=generic arch=linux-ubuntu18.04-x86_64
[+]  cpmynty		  ^gdbm@1.23%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  k2lfw6f	      ^pkgconf@1.8.0%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  76ul6un	      ^pmix@4.1.2%gcc@7.5.0~docs+pmi_backwards_compatibility~restful build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  nblr6w4		  ^libevent@2.1.12%gcc@7.5.0+openssl build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  2hfr5rb	      ^zlib@1.2.13%gcc@7.5.0+optimize+pic+shared build_system=makefile arch=linux-ubuntu18.04-x86_64
[+]  nwawfek	  ^scr@2.0.0%gcc@7.5.0+dtcmp~fortran~ipo+libyogrt async_api=NONE build_system=cmake build_type=RelWithDebInfo cache_base=/dev/shm cntl_base=/dev/shm copy_config=none file_lock=FLOCK resource_manager=SLURM scr_config=scr.conf arch=linux-ubuntu18.04-x86_64
[+]  jpa7i2q	      ^dtcmp@1.1.4%gcc@7.5.0+shared build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  it5zkjf		  ^lwgrp@1.0.5%gcc@7.5.0+shared build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  kv6hvaf	      ^libyogrt@1.27%gcc@7.5.0~static build_system=autotools scheduler=slurm arch=linux-ubuntu18.04-x86_64
[+]  p2tmqkb		  ^slurm@21-08-8-2%gcc@7.5.0~gtk~hdf5~hwloc~mariadb~pmix+readline~restd build_system=autotools sysconfdir=PREFIX/etc arch=linux-ubuntu18.04-x86_64
[+]  wc2juod		      ^curl@7.85.0%gcc@7.5.0~gssapi~ldap~libidn2~librtmp~libssh~libssh2~nghttp2 build_system=autotools libs=shared,static tls=openssl arch=linux-ubuntu18.04-x86_64
[+]  z5u7d3q		      ^glib@2.74.1%gcc@7.5.0~libmount build_system=generic tracing=none arch=linux-ubuntu18.04-x86_64
[+]  qzq4b7h			  ^libffi@3.4.2%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  z43z3fa			  ^meson@0.63.3%gcc@7.5.0 build_system=python_pip patches=aa6c50d arch=linux-ubuntu18.04-x86_64
[+]  bfqiunh			      ^py-pip@22.2.2%gcc@7.5.0 build_system=generic arch=linux-ubuntu18.04-x86_64
[+]  xik3yv6			      ^py-setuptools@65.5.0%gcc@7.5.0 build_system=generic arch=linux-ubuntu18.04-x86_64
[+]  4yhmu3f			      ^py-wheel@0.37.1%gcc@7.5.0 build_system=generic arch=linux-ubuntu18.04-x86_64
[+]  ml4nwp3			  ^ninja@1.11.1%gcc@7.5.0 build_system=generic arch=linux-ubuntu18.04-x86_64
[+]  gtbod2d			  ^pcre2@10.39%gcc@7.5.0~jit+multibyte build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  cyf55fe			  ^python@3.10.8%gcc@7.5.0+bz2+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tix~tkinter~ucs4+uuid+zlib build_system=generic patches=0d98e93,7d40923,f2fd060 arch=linux-ubuntu18.04-x86_64
[+]  j5k5nzg			      ^expat@2.4.8%gcc@7.5.0+libbsd build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  qieib3t				  ^libbsd@0.11.5%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  miq3rrs				      ^libmd@1.0.4%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  vmf7qax			      ^sqlite@3.39.4%gcc@7.5.0+column_metadata+dynamic_extensions+fts~functions+rtree build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  eayyoxj			      ^util-linux-uuid@2.38.1%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  wwi7hmc		      ^json-c@0.16%gcc@7.5.0~ipo build_system=cmake build_type=RelWithDebInfo arch=linux-ubuntu18.04-x86_64
[+]  grcwjnc		      ^lz4@1.9.4%gcc@7.5.0 build_system=makefile libs=shared,static arch=linux-ubuntu18.04-x86_64
[+]  llrb4kh		      ^munge@0.5.15%gcc@7.5.0 build_system=autotools localstatedir=PREFIX/var arch=linux-ubuntu18.04-x86_64
[+]  xnc35ij			  ^libgcrypt@1.10.1%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  m6alhez			      ^libgpg-error@1.46%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  nybpksa				  ^gawk@5.1.1%gcc@7.5.0~nls build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  iowhen4				      ^gmp@6.2.1%gcc@7.5.0 build_system=autotools libs=shared,static arch=linux-ubuntu18.04-x86_64
[+]  h4tcmq3				      ^mpfr@4.1.0%gcc@7.5.0 build_system=autotools libs=shared,static arch=linux-ubuntu18.04-x86_64
[+]  hdyi7fu					  ^texinfo@6.5%gcc@7.5.0 build_system=autotools patches=12f6edb,1732115 arch=linux-ubuntu18.04-x86_64
[+]  2uj3346	      ^pdsh@2.31%gcc@7.5.0+ssh+static_modules build_system=autotools arch=linux-ubuntu18.04-x86_64
[+]  v2i3mr5	  ^silo@4.10.2%gcc@7.5.0~fortran+fpzip+hdf5+hzip+mpi+pic+shared~silex build_system=autotools patches=3a1e831,7b5a1dc,eb2a3a0,fa050e0 arch=linux-ubuntu18.04-x86_64
[+]  rolnbco	      ^autoconf-archive@2022.02.11%gcc@7.5.0 build_system=autotools patches=139214f arch=linux-ubuntu18.04-x86_64
[+]  xfftbwl	      ^hdf5@1.12.2%gcc@7.5.0~cxx~fortran~hl~ipo~java+mpi+shared~szip~threadsafe+tools api=default build_system=cmake build_type=RelWithDebInfo arch=linux-ubuntu18.04-x86_64
[+]  kgyvtw5	      ^readline@8.1.2%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64

==> Concretized unzip
 -   pqjekjj  unzip@6.0%gcc@7.5.0 build_system=makefile arch=linux-ubuntu18.04-x86_64

==> Installing environment /home/spack/cache-env
==> Installing unzip-6.0-pqjekjjxs5ldhonqz5epltw275ylg27f
==> Fetching file:///mirror/build_cache/linux-ubuntu18.04-x86_64-gcc-7.5.0-unzip-6.0-pqjekjjxs5ldhonqz5epltw275ylg27f.spec.json.sig
==> Fetching file:///mirror/build_cache/linux-ubuntu18.04-x86_64/gcc-7.5.0/unzip-6.0/linux-ubuntu18.04-x86_64-gcc-7.5.0-unzip-6.0-pqjekjjxs5ldhonqz5epltw275ylg27f.spack
==> Extracting unzip-6.0-pqjekjjxs5ldhonqz5epltw275ylg27f from binary cache
==> unzip: Successfully installed unzip-6.0-pqjekjjxs5ldhonqz5epltw275ylg27f
  Fetch: 0.16s.	 Build: 0.24s.	Total: 0.39s.
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/unzip-6.0-pqjekjjxs5ldhonqz5epltw275ylg27f
==> Updating view at /home/spack/cache-env/.spack-env/view

Now that we’ve added unzip, we need to update the mirror.

$ spack mirror create -d ~/mirror --all
==> Adding package autoconf@2.69 to mirror
==> Adding package autoconf-archive@2022.02.11 to mirror
==> Adding package automake@1.16.5 to mirror
==> Adding package berkeley-db@18.1.40 to mirror
==> Adding package bison@3.8.2 to mirror
==> Adding package bzip2@1.0.8 to mirror
==> Adding package ca-certificates-mozilla@2022-10-11 to mirror
==> Adding package cmake@3.24.3 to mirror
==> Adding package curl@7.85.0 to mirror
==> Adding package diffutils@3.8 to mirror
==> Adding package dtcmp@1.1.4 to mirror
==> Adding package expat@2.4.8 to mirror
==> Adding package gawk@5.1.1 to mirror
==> Adding package gdbm@1.23 to mirror
==> Adding package gettext@0.21.1 to mirror
==> Adding package glib@2.74.1 to mirror
==> Adding package gmp@6.2.1 to mirror
==> Adding package hdf5@1.12.2 to mirror
==> Adding package hwloc@2.8.0 to mirror
==> Adding package json-c@0.16 to mirror
==> Adding package json-cwx@0.12 to mirror
==> Adding package krb5@1.19.3 to mirror
==> Adding package libbsd@0.11.5 to mirror
==> Adding package libedit@3.1-20210216 to mirror
==> Adding package libevent@2.1.12 to mirror
==> Adding package libffi@3.4.2 to mirror
==> Adding package libgcrypt@1.10.1 to mirror
==> Adding package libgpg-error@1.46 to mirror
==> Adding package libiconv@1.16 to mirror
==> Adding package libmd@1.0.4 to mirror
==> Adding package libpciaccess@0.16 to mirror
==> Adding package libsigsegv@2.13 to mirror
==> Adding package libtool@2.4.7 to mirror
==> Adding package libxml2@2.10.1 to mirror
==> Adding package libyogrt@1.27 to mirror
==> Adding package lwgrp@1.0.5 to mirror
==> Adding package lz4@1.9.4 to mirror
==> Adding package m4@1.4.19 to mirror
==> Adding package macsio@1.1 to mirror
==> Adding package meson@0.63.3 to mirror
==> Adding package mpfr@4.1.0 to mirror
==> Adding package munge@0.5.15 to mirror
==> Adding package ncurses@6.3 to mirror
==> Adding package ninja@1.11.1 to mirror
==> Adding package numactl@2.0.14 to mirror
==> Adding package openmpi@4.1.4 to mirror
==> Adding package openssh@9.1p1 to mirror
==> Adding package openssl@1.1.1s to mirror
==> Adding package pcre2@10.39 to mirror
==> Adding package pdsh@2.31 to mirror
==> Adding package perl@5.36.0 to mirror
==> Adding package pigz@2.7 to mirror
==> Adding package pkgconf@1.8.0 to mirror
==> Adding package pmix@4.1.2 to mirror
==> Adding package py-pip@22.2.2 to mirror
==> Adding package py-setuptools@65.5.0 to mirror
==> Adding package py-wheel@0.37.1 to mirror
==> Adding package python@3.10.8 to mirror
==> Adding package readline@8.1.2 to mirror
==> Adding package scr@2.0.0 to mirror
==> Adding package silo@4.10.2 to mirror
==> Adding package slurm@21-08-8-2 to mirror
==> Adding package sqlite@3.39.4 to mirror
==> Adding package tar@1.34 to mirror
==> Adding package texinfo@6.5 to mirror
==> Adding package unzip@6.0 to mirror
==> Fetching https://mirror.spack.io/_source-cache/archive/03/036d96991646d0449ed0aa952e4fbe21b476ce994abc276e49d30e686708bd37.tar.gz
==> Adding package util-linux-uuid@2.38.1 to mirror
==> Adding package util-macros@1.19.3 to mirror
==> Adding package xz@5.2.7 to mirror
==> Adding package zlib@1.2.13 to mirror
==> Adding package zstd@1.5.2 to mirror
==> Summary for mirror in /home/spack/mirror
==> Archive stats:
    70	 already present
    1	 added
    0	 failed to fetch.

Spack will skip uploading source code packages that are already included in the spack mirror. Mirrors can be shared across different environments, meaning one mirror can house all the source code needed to build your team’s dependencies.

Setting up a binary cache mirror

If you’re going to be setting up a team to use spack as part of their development practice, you’ll run up against the biggest disadvantage to using spack: building all your packages from scratch is slow. Recompiling the software dependencies for a large project can take hours to complete. If every developer is rebuilding their own software stack, that leads to a massive waste of computational resources and a loss of developer productivity.

Spack has two ways to help alleviate this problem: chained spack instances and spack binary caches. For now, we’re going to discuss spack binary caches as a way of solving this issue.

A spack binary cache is made up of spack binary packages. Each spack binary package, ending with a *.spack extension, is a tarball of an installed spack package signed with a gpg signature. When you install a package from a mirror with a binary cache, spack

  • Checks to see if there is a spack binary package that exactly matches the hash of the spec you want to build.
  • If a binary package is found, spack checks to see if the signature on the spack binary package is trusted. If the signature isn’t trusted or no package was found, spack builds the package from source.
  • If the signature is trusted, then spack unzips and relocates the spack package.

For the user, spack binary caches are transparent to use. This is a clear departure from systems like conda, where you need to chose separate workflows for binary and source packages. We’ve already demonstrated using spack binary caches earlier in the tutorial when we set up spack to use a binary mirror. As a reminder, we ran:

$ spack mirror add tutorial /mirror
$ spack buildcache keys --install --trust
==> Fetching file:///mirror/build_cache/_pgp/78F3726939CA1B94893B66E8BC86F6FB94429164.pub
gpg: key A8E0CA3C1C2ADA2F: 7 signatures not checked due to missing keys
gpg: key A8E0CA3C1C2ADA2F: public key "Spack Project Official Binaries <maintainers@spack.io>" imported
gpg: Total number processed: 1
gpg:		   imported: 1
gpg: no ultimately trusted keys found
gpg: inserting ownertrust of 6

Building a spack binary cache has some gotchas, but is almost as easy as building a source mirror. We’ll start by making a new environment for ourselves. Since we’re intending to publish to a binary cache, we’ll need to compile all these packages ourselves. This can take some time, so we’ll make a new environment with some packages that compile quickly.

$ cd ~
$ mkdir cache-binary
$ cd cache-binary
$ spack env create -d .
==> Created environment in /home/spack/cache-binary
==> You can activate this environment with:
==>   spack env activate /home/spack/cache-binary
$ spacktivate .
$ spack add bzip2
==> Adding bzip2 to environment /home/spack/cache-binary
$ spack add zlib
==> Adding zlib to environment /home/spack/cache-binary

Before we build anything, we need to modify the following line in our spack configuration file. Then, just to be sure, we’ll initiate a build of this environment and force ourselves to not use any cache.

$ spack config add "config:install_tree:padded_length:128"
$ spack install --no-cache
==> Concretized bzip2
 -   cxcreln  bzip2@1.0.8%gcc@7.5.0~debug~pic+shared build_system=generic arch=linux-ubuntu18.04-x86_64
 -   c3uhkcj	  ^diffutils@3.8%gcc@7.5.0 build_system=autotools arch=linux-ubuntu18.04-x86_64
 -   ltvovvv	      ^libiconv@1.16%gcc@7.5.0 build_system=autotools libs=shared,static arch=linux-ubuntu18.04-x86_64

==> Concretized zlib
 -   2hfr5rb  zlib@1.2.13%gcc@7.5.0+optimize+pic+shared build_system=makefile arch=linux-ubuntu18.04-x86_64

==> Installing environment /home/spack/cache-binary
==> Installing libiconv-1.16-ltvovvvjgmlvy4m2pn365cy6p5dysajq
==> Fetching https://mirror.spack.io/_source-cache/archive/e6/e6a1b1b589654277ee790cce3734f07876ac4ccfaecbee8afa0b649cf529cc04.tar.gz
==> No patches needed for libiconv
==> libiconv: Executing phase: 'autoreconf'
==> libiconv: Executing phase: 'configure'
==> libiconv: Executing phase: 'build'
==> libiconv: Executing phase: 'install'
==> libiconv: Successfully installed libiconv-1.16-ltvovvvjgmlvy4m2pn365cy6p5dysajq
  Fetch: 0.31s.	 Build: 14.91s.	 Total: 15.22s.
[+] /home/spack/spack/opt/spack/[padded-to-128-chars]/linux-ubuntu18.04-x86_64/gcc-7.5.0/libiconv-1.16-ltvovvvjgmlvy4m2pn365cy6p5dysajq
==> Installing zlib-1.2.13-2hfr5rbzefrxf6t6kv4trbsl63puaza6
==> Fetching https://mirror.spack.io/_source-cache/archive/b3/b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30.tar.gz
==> No patches needed for zlib
==> zlib: Executing phase: 'edit'
==> zlib: Executing phase: 'build'
==> zlib: Executing phase: 'install'
==> zlib: Successfully installed zlib-1.2.13-2hfr5rbzefrxf6t6kv4trbsl63puaza6
  Fetch: 0.47s.	 Build: 0.84s.	Total: 1.32s.
[+] /home/spack/spack/opt/spack/[padded-to-128-chars]/linux-ubuntu18.04-x86_64/gcc-7.5.0/zlib-1.2.13-2hfr5rbzefrxf6t6kv4trbsl63puaza6
==> Installing diffutils-3.8-c3uhkcjt7tagz2djrd6r2b6b3c2tia3s
==> Fetching https://mirror.spack.io/_source-cache/archive/a6/a6bdd7d1b31266d11c4f4de6c1b748d4607ab0231af5188fc2533d0ae2438fec.tar.xz
==> No patches needed for diffutils
==> diffutils: Executing phase: 'autoreconf'
==> diffutils: Executing phase: 'configure'
==> diffutils: Executing phase: 'build'
==> diffutils: Executing phase: 'install'
==> diffutils: Successfully installed diffutils-3.8-c3uhkcjt7tagz2djrd6r2b6b3c2tia3s
  Fetch: 0.33s.	 Build: 20.63s.	 Total: 20.96s.
[+] /home/spack/spack/opt/spack/[padded-to-128-chars]/linux-ubuntu18.04-x86_64/gcc-7.5.0/diffutils-3.8-c3uhkcjt7tagz2djrd6r2b6b3c2tia3s
==> Installing bzip2-1.0.8-cxcrelnw64jh6lvhzb6pfar7nijv6us6
==> Fetching https://mirror.spack.io/_source-cache/archive/ab/ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269.tar.gz
==> Ran patch() for bzip2
==> bzip2: Executing phase: 'install'
==> bzip2: Successfully installed bzip2-1.0.8-cxcrelnw64jh6lvhzb6pfar7nijv6us6
  Fetch: 0.28s.	 Build: 1.20s.	Total: 1.48s.
[+] /home/spack/spack/opt/spack/[padded-to-128-chars]/linux-ubuntu18.04-x86_64/gcc-7.5.0/bzip2-1.0.8-cxcrelnw64jh6lvhzb6pfar7nijv6us6
==> Updating view at /home/spack/cache-binary/.spack-env/view

This configuration change ensures that spack installs all our packages to a path that is at least 128 characters. We need this change because of how spack relocates packages. Relocation consists of the following steps:

  • Search all text files to replace the package builder’s path with your specific local installation path.
  • Modify all the RPATHs in your binaries to point to your specific local installation path. This uses patchelf if the new path is longer than the old path, but otherwise uses a faster implementation in python.
  • Search all binaries to replace hard-coded C strings of the package builder’s path with your specific local installation path.

Adding padding ensures that any paths hard-coded as C strings in our binaries will be large enough to hold our user’s eventual install path. We advise picking 128 because longer strings occasionally cause compilation problems with some software packages. If the user’s install path is too long, spack will give you a warning. All scripts and and RPATHs will still be properly relocated, but C strings within any binaries will not be modified. Depending on the package, this may cause problems when you try and use the software.

We also need to create a gpg key to sign all our packages. You should back up the secret and public keys to a secure place so they can be re-used in the future.

$ spack gpg create "My Name" "<my.email@my.domain.com>"
gpg: key CB27D219F97A56CE marked as ultimately trusted
gpg: directory '/home/spack/spack/opt/spack/gpg/openpgp-revocs.d' created
gpg: revocation certificate stored as '/home/spack/spack/opt/spack/gpg/openpgp-revocs.d/32AA3EB465F13246DB890BBFCB27D219F97A56CE.rev'
$ mkdir ~/private_gpg_backup
$ cp ~/spack/opt/spack/gpg/*.gpg ~/private_gpg_backup
$ cp ~/spack/opt/spack/gpg/pubring.* ~/mirror

With this setup done, we’re ready to fill a binary cache with binary packages. Binary packages are attached to an existing source mirror. We follow the same steps we used for the source mirror – making an environment, creating the source mirror, and building the packages to a spack installation with our padded path. To upload a spec to a binary cache, simply use the command spack buildcache create --only=package spec. Here we use the spack find --format command that we will discuss in more detail in the Scripting section of the tutorial to operate on all specs in the environment.

$ spack buildcache create --allow-root --force -d ~/mirror --only=package $(spack find --format /{hash})
==> Pushing binary packages to file:///home/spack/mirror/build_cache
gpg: checking the trustdb
gpg: marginals needed: 3  completes needed: 1  trust model: pgp
gpg: depth: 0  valid:	2  signed:   0	trust: 0-, 0q, 0n, 0m, 0f, 2u

Voila, done! Our spack mirror has now been augmented with a binary cache. This cache can be used on systems without external internet access, just like with a spack source mirror. As always, remember to update the file permissions after updating the mirror.

$ umask 750
$ chmod -R g+rs ~/mirror
$ chgrp -R spack ~/mirror

Though it’s outside the scope of this tutorial, spack mirrors and build caches can also be hosted over https:// and s3:// as well. Consult the spack documentation for more information on how to do this.

Before a user can use this binary cache, they will need to make sure that they trust all the packages listed in the binary cache. If you’re sharing files between trusted users on a filesystem, you can do this with the following command:

$ spack buildcache keys --install --trust --force
==> Fetching file:///mirror/build_cache/_pgp/78F3726939CA1B94893B66E8BC86F6FB94429164.pub
gpg: key A8E0CA3C1C2ADA2F: 7 signatures not checked due to missing keys
gpg: key A8E0CA3C1C2ADA2F: "Spack Project Official Binaries <maintainers@spack.io>" not changed
gpg: Total number processed: 1
gpg:		  unchanged: 1

Together, this means download all the keys on the binary cache and trust them. Have your users run the above command on a new spack instance before they initiate a build.

Bootstrapping Mirrors

In order to run Spack on an airgapped system or aywhere else without internet access, you also need to install clingo as a dependency of the concretizer. While you can always install clingo through your favorite method, we like to think Spack is your favorite install mechanism for everything, and we have convenient ways to bootstrap clingo on airgapped systems.

Spack can prepare a bootstrap mirror for either source or binary mirror for bootstrapping via the spack bootstrap mirror command. We will focus on binary bootstrapping for this tutorial.

$ spack bootstrap mirror --binary-packages ~/mirror
==> Adding "clingo-bootstrap@spack+python %gcc target=x86_64" and dependencies to the mirror at /home/spack/mirror/bootstrap_cache
==> Adding "gnupg@2.3: %gcc target=x86_64" and dependencies to the mirror at /home/spack/mirror/bootstrap_cache
==> Adding "patchelf@0.13.1: %gcc target=x86_64" and dependencies to the mirror at /home/spack/mirror/bootstrap_cache
==> Adding "gnuconfig" and dependencies to the mirror at /home/spack/mirror/bootstrap_cache
==> Adding binary packages from "https://github.com/spack/spack-bootstrap-mirrors/releases/download/v0.4/bootstrap-buildcache.tar.gz" to the mirror at /home/spack/mirror/bootstrap_cache

To register the mirror on the platform where it's supposed to be used, move "/home/spack/mirror" to its final location and run the following command(s):

  % spack bootstrap add --trust local-sources <final-path>/metadata/sources
  % spack bootstrap add --trust local-binaries <final-path>/metadata/binaries

Using the instructions printed from Spack, you can register the new bootstrap sources on the airgapped system.

Cache Summary

If you’re using spack within a development team, consider setting up source mirrors with binary caches. Source mirrors will let you replicate a spack environment on a machine without external internet access, and binary mirrors free you from the burden of recompiling everything from scratch and save you development time. Spack mirrors also provide the mechanism to bring Spack’s internal dependencies over to any machine without external internet access.