ACCESS-NRI Spack Cheat Sheet

ACCESS-NRI Spack Cheat Sheet

This document focuses on Spack v1 and newer.

The latest version of Spack, maintained by ACCESS-NRI, can be loaded by running:

 module use /g/data/vk83/modules
 module load spack

Can Spack find existing system installed compilers?

  • Yes, run spack compiler find

Can Spack simulate spack install <spec> concretization step?

  • spack solve <spec>

How do I manage Spack repositories that contain Spack Package Recipes?

  • spack repo <command>
  • spack repo --help

How do I edit a Spack Package Recipe in a Spack managed repository?

  • spack edit <SPR-name>

What happened to ACCESS-NRI’s spack-packages directory?

  • ACCESS-NRI renamed our spack-packages repository to access-spack-packages. Unlike Spack v0.22, Spack v1.1 manages the ACCESS-NRI repository for the end user. Run spack repo list to see all the repositories managed by Spack.

Can git be used on Spack managed repositories?

  • Yes. e.g. git -C $spack/../package_repos/3t2klr5 log
  • If the repository is a shallow clone, run git fetch --unshallow $spack/../package_repos/3t2klr5 to get full Git functionality.

Can externals be added to a spack.yaml environment file?

  • Yes!

Why is Spack using a mixture of underscore (“_”) and hypen (“-”) in the names of directories and files?

How to modify an existing repo in repos.yaml from a higher precedence scope:

[root@5ca9101ef997 site]# spack config blame repos
---                                      repos:
/opt/spack/etc/spack/site/repos.yaml:3     access_spack_packages:
/opt/spack/etc/spack/site/repos.yaml:4       git: https://github.com/ACCESS-NRI/access-spack-packages.git
/opt/spack/etc/spack/site/repos.yaml:5       branch: api-v2
/opt/spack/etc/spack/site/repos.yaml:6       destination: $spack/../access-spack-packages
/opt/spack/etc/spack/site/repos.yaml:7     builtin:
/opt/spack/etc/spack/site/repos.yaml:8       git: https://github.com/spack/spack-packages.git
/opt/spack/etc/spack/site/repos.yaml:10      commit: 2f02a99ec9dfd5dceb9bd91abc392edabd9ba963

[root@5ca9101ef997 site]# spack repo add --scope=user --name builtin https://github.com/spack/spack-packages.git 
==> Added repo to config with name 'builtin'.

[root@5ca9101ef997 site]# spack repo update --scope=user --commit 383e969358c951abe17623696083e6f862c4488e builtin
==> builtin: Already up to date.

[root@5ca9101ef997 site]# spack config blame repos
---                                     repos:
/root/.spack/repos.yaml:2                 builtin:
/root/.spack/repos.yaml:3                   git: https://github.com/spack/spack-packages.git
/root/.spack/repos.yaml:4                   commit: 383e969358c951abe17623696083e6f862c4488e
/opt/spack/etc/spack/site/repos.yaml:3    access_spack_packages:
/opt/spack/etc/spack/site/repos.yaml:4      git: https://github.com/ACCESS-NRI/access-spack-packages.git
/opt/spack/etc/spack/site/repos.yaml:5      branch: api-v2
/opt/spack/etc/spack/site/repos.yaml:6      destination: $spack/../access-spack-packages

The Spack concretizer chose the wrong package!

The Spack v1 concretizer is opinionated! The Spack Package Recipe contained:

    depends_on("c", type="build")
    depends_on("fortran", type="build")
    depends_on("mpi")

    build_system("cmake", "makefile", default="cmake")

However, the Spack concretizer chose makefile even though cmake was the default:

 -   access-mocsy@stable build_system=makefile commit=b136e1a70b9959333b0258b07863ebb05c4ff5f7 platform=linux os=rocky8 target=x86_64 %c,cxx,fortran=gcc@13.2.0

Spack upstream found that this decision was made because the cmake version we had required was deprecated, even though using deprecated versions was enabled by setting deprecated: True was set in config.yaml.

Running spack solve can help with debugging:

--- cmake.txt	2026-03-13 11:03:18.643378274 +1100
+++ makefile.txt	2026-03-13 11:02:53.490965502 +1100
@@ -1,13 +1,12 @@
-[test] [root@e5843698fd94 test]# spack solve access-mocsy build_system=cmake
+[test] [root@e5843698fd94 opt]# spack solve access-mocsy build_system=makefile
 ==> SOLVING SPEC:
-  access-mocsy build_system=cmake
-==> Warning: using "cmake@3.31.6" which is a deprecated version
+  access-mocsy build_system=makefile
 ==> Warning: Unable to resolve the git commit for access-mocsy. An installation of this binary won't have complete binary provenance.
 ==> Best of 5 considered solutions.
 
   Priority  Value  Criterion
          1      0  requirement weight                                   
-         2      1  deprecated versions used                             
+         2      0  deprecated versions used                             
          3      0  version badness (roots)                              
          4      0  number of non-default variants (roots)               
          5      0  preferred providers for roots

What data do you need to debug Spack?

  • spack debug report
  • spack config blame
  • spack config scopes --verbose include

Spack install failure on Gadi’s /scratch filesystem, files/directories required for the build are missing and some have a “Jan 1 1970” modification time.

  • Suspected file or filesystem corruption.
  • Try renaming/deleting the spack-stage directory. e.g. spack-stage-um7-git.2026.04.000_access-esm1.6-bdlpvvfpydgedzzktzviqovdeb3fyzbt
  • Try renaming/deleting the source cache tarball. e.g. source_cache/_source-cache/git/ACCESS-NRI/UM7.git/06f9a279d092542637342e8d71a70f1a42fd2df8.tar.gz

How to list only locally installed packages:

  • spack find --install-tree local

How to list only upstream installed packages:

  • Run spack config get upstreams to see the names of available upstreams.
  • spack find --install-tree <name-of-upstream>

How do I compile a package with Score-P instrumentation?

  • Here’s an example for Fortran code:
export SPACK_FC=scorep-ftn
spack install <package>
  • Relevent environment variables are: SPACK_CC, SPACK_CXX, SPACK_F77, SPACK_FC
  • Have a look at the compiler wrapper repos/spack_repo/builtin/packages/compiler_wrapper/cc.sh in spack-packages to see which environment variables are available.

What do the symbols at the start of spack concretize output mean?

  • [e] - The spec is an external. e.g.
[e]  ywivpoa                      ^perl@5.26.3+cpanm+opcode+open+shared+threads build_system=generic platform=linux os=rocky8 target=x86_64
  • [^] - The spec is in an upstream. e.g.
[^]  mxv42tq                      ^tar@1.35 build_system=autotools zip=pigz arch=linux-rocky8-x86_64 %c=gcc@13.2.0
  • [-] - The spec needs to be built and installed. e.g.
[-]  gxytk5a          ^cmake@3.31.11~doc+ncurses+ownlibs~qtgui build_system=generic build_type=Release platform=linux os=rocky8 target=x86_64 %c,cxx=intel@2021.10.0
  • [+] - The spec is already installed locally. e.g.
[+]  gxytk5a          ^cmake@3.31.11~doc+ncurses+ownlibs~qtgui build_system=generic build_type=Release platform=linux os=rocky8 target=x86_64 %c,cxx=intel@2021.10.0

new prefix is longer.

  • We have seen this issue with Spack v0.22.

  • Error: spack.installer.InstallError: Terminating after first install failure: Cannot replace b'[..]' with b'[..]' because the new prefix is longer. To fix this, compile with more padding (config:install_tree:padded_length), or install to a shorter prefix.

  • Delete the entry/package from the buildcache.

How to find all installed packages while in an environment

  • If you wish to find all installed packages, including those outside the current environment, run:
spack -E find 

How to add an editable Spack repository