Skip to content

Developing with "spack develop"

Imagine that you want to modify some portions of Kokkos for your application. Recall that although Kokkos is not explicitly listed as a spec, it is included in the environment because Cabana depends on Kokkos. One option is to build and install Kokkos manually and link it to your project. But since Cabana depends on Kokkos and a project can't use two different versions of Kokkos, you will also need to install Cabana and link it to your Kokkos installation.

Spack includes a feature that lets you modify the code of any (non-binary) library in a Spack environment. Let's go back to the Cabana example. Activate the environment with Cabana, run the command spack develop kokkos@[version] (such as Kokkos@4.6), then re-concretize the environment. Spack will clone the Kokkos repository of the correct version in the directory with the spack.yaml file and modify the spack.yaml file as follows:

spack:
  specs:
    # Install from code in the master branch of Cabana on Github. Include Cabana::Grid headers and install with CUDA and MPI support. 
    - cabana@master +grid +cuda +mpi
  develop:
    kokkos:
      spec: kokkos@=[version]

Now, you can edit the source code of Kokkos, and next time you run spack install, spack will build and install Kokkos using the files that are in the directory with the spack.yaml file rather than fetching a version of Kokkos from GitHub.