Environments Tutorial

We’ve shown you how to install and remove packages with Spack. You can use spack install to install packages, spack uninstall to remove them, and spack find to look at and query what is installed. We’ve also shown you how to customize Spack’s installation with configuration files like packages.yaml.

If you build a lot of software, or if you work on multiple projects, managing everything in one place can be overwhelming. The default spack find output may contain many packages, but you may want to just focus on packages for a particular project. Moreover, you may want to include special configuration with your package groups, e.g., to build all the packages in the same group the same way.

Spack environments provide a way to handle these problems.

Environment Basics

Let’s look at the output of spack find at this point in the tutorial.

$ spack find
==> 70 installed packages
-- linux-ubuntu18.04-x86_64 / clang@6.0.0 -----------------------
zlib@1.2.11

-- linux-ubuntu18.04-x86_64 / gcc@7.5.0 -------------------------
adept-utils@1.0.1  gettext@0.20.2     libiberty@2.33.1	   mumps@5.3.3		   pkgconf@1.7.3
autoconf@2.69	   glm@0.9.7.1	      libiconv@1.16	   ncurses@6.2		   readline@8.0
automake@1.16.2    gmp@6.1.2	      libpciaccess@0.13.5  netcdf-c@4.7.3	   suite-sparse@5.7.2
boost@1.72.0	   hdf5@1.10.6	      libsigsegv@2.12	   netcdf-c@4.7.3	   tar@1.32
boost@1.73.0	   hdf5@1.10.6	      libtool@2.4.6	   netlib-scalapack@2.1.0  tcl@8.6.8
bzip2@1.0.8	   hdf5@1.10.6	      libxml2@2.9.10	   netlib-scalapack@2.1.0  tcl@8.6.8
callpath@1.0.4	   hdf5@1.10.6	      m4@1.4.18 	   numactl@2.0.12	   texinfo@6.5
cmake@3.17.3	   hwloc@1.11.11      matio@1.5.13	   openblas@0.3.10	   trilinos@12.18.1
diffutils@3.7	   hwloc@2.2.0	      matio@1.5.13	   openmpi@3.1.6	   util-macros@1.19.1
dyninst@10.1.0	   hypre@2.18.2       metis@5.1.0	   openssl@1.1.1g	   xz@5.2.5
elfutils@0.179	   hypre@2.18.2       mpc@1.1.0 	   parmetis@4.0.3	   zlib@1.2.8
findutils@4.6.0    intel-tbb@2020.2   mpfr@3.1.6	   parmetis@4.0.3	   zlib@1.2.8
gcc@8.3.0	   isl@0.18	      mpich@3.3.2	   patchelf@0.10	   zlib@1.2.11
gdbm@1.18.1	   libdwarf@20180129  mumps@5.3.3	   perl@5.30.3

This is a complete, but cluttered view. There are packages built with both openmpi and mpich, as well as multiple variants of other packages, like zlib. The query mechanism we learned about in spack find can help, but it would be nice if we could start from a clean slate without losing what we’ve already done.

Creating and activating environments

The spack env command can help. Let’s create a new environment:

$ spack env create myproject
==> Updating view at /home/spack/spack/var/spack/environments/myproject/.spack-env/view
==> Created environment 'myproject' in /home/spack/spack/var/spack/environments/myproject
==> You can activate this environment with:
==>   spack env activate myproject

An environment is a virtualized spack instance that you can use for a specific purpose. The environment also has an associated view, which is a single prefix where all packages from the environment are linked.

You can see the environments we’ve created so far like this:

$ spack env list
==> 1 environments
    myproject

And you can activate an environment with spack env activate:

$ spack env activate myproject

Once you enter an environment, spack find shows only what is in the current environment. We just created this environment, so we have a clean slate – 0 packages:

$ spack find
==> In environment myproject
==> No root specs
==> 0 installed packages

The spack find output is still slightly different. It tells you that you’re in the myproject environment, so that you don’t panic when you see that there is nothing installed. It also says that there are no root specs. We’ll get back to what that means later.

If you only want to check what environment you are in, you can use spack env status:

$ spack env status
==> In environment myproject

If you want to leave this environment and go back to normal Spack, you can use spack env deactivate. We like to use the despacktivate alias (which Spack sets up automatically) for short:

$ despacktivate      short alias for
$ spack env status
==> No active environment
$ spack find
==> 70 installed packages
-- linux-ubuntu18.04-x86_64 / clang@6.0.0 -----------------------
zlib@1.2.11

-- linux-ubuntu18.04-x86_64 / gcc@7.5.0 -------------------------
adept-utils@1.0.1  gettext@0.20.2     libiberty@2.33.1	   mumps@5.3.3		   pkgconf@1.7.3
autoconf@2.69	   glm@0.9.7.1	      libiconv@1.16	   ncurses@6.2		   readline@8.0
automake@1.16.2    gmp@6.1.2	      libpciaccess@0.13.5  netcdf-c@4.7.3	   suite-sparse@5.7.2
boost@1.72.0	   hdf5@1.10.6	      libsigsegv@2.12	   netcdf-c@4.7.3	   tar@1.32
boost@1.73.0	   hdf5@1.10.6	      libtool@2.4.6	   netlib-scalapack@2.1.0  tcl@8.6.8
bzip2@1.0.8	   hdf5@1.10.6	      libxml2@2.9.10	   netlib-scalapack@2.1.0  tcl@8.6.8
callpath@1.0.4	   hdf5@1.10.6	      m4@1.4.18 	   numactl@2.0.12	   texinfo@6.5
cmake@3.17.3	   hwloc@1.11.11      matio@1.5.13	   openblas@0.3.10	   trilinos@12.18.1
diffutils@3.7	   hwloc@2.2.0	      matio@1.5.13	   openmpi@3.1.6	   util-macros@1.19.1
dyninst@10.1.0	   hypre@2.18.2       metis@5.1.0	   openssl@1.1.1g	   xz@5.2.5
elfutils@0.179	   hypre@2.18.2       mpc@1.1.0 	   parmetis@4.0.3	   zlib@1.2.8
findutils@4.6.0    intel-tbb@2020.2   mpfr@3.1.6	   parmetis@4.0.3	   zlib@1.2.8
gcc@8.3.0	   isl@0.18	      mpich@3.3.2	   patchelf@0.10	   zlib@1.2.11
gdbm@1.18.1	   libdwarf@20180129  mumps@5.3.3	   perl@5.30.3

Phew – all of our packages are still installed.

Installing packages

Ok, now that we understand how creation and activation work, let’s go back to myproject and install a few packages:


$ spack env activate myproject
$ spack install tcl
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/zlib-1.2.11-smoyzzo2qhzpn6mg6rd3l2p7b23enshg
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/tcl-8.6.8-aszidznovy2kcbefk4dexwf5mlrjbbcw
==> Updating view at /home/spack/spack/var/spack/environments/myproject/.spack-env/view
$ spack install trilinos
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libiconv-1.16-jearpk4xci4zc7dkrza4fufaqfkq7rfl
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/zlib-1.2.11-smoyzzo2qhzpn6mg6rd3l2p7b23enshg
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/pkgconf-1.7.3-4sh6pymrm2ms4auu3ajbjjr6fiuhz5g7
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libsigsegv-2.12-lbrx7lnfz46ukewxbhxnucmx76g23c6q
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/util-macros-1.19.1-gs6ag7ktdoiirb62t7bcagjw62szrrg2
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/xz-5.2.5-6nxes4rhk52rhxj7dntwqa5nzou5sv2t
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/openblas-0.3.10-m5gktgohkqi2znlic6cwpz5euhqdle3i
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/diffutils-3.7-otkktenrrvcaf37a7zyeytmjuwsalvtr
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/ncurses-6.2-crhlefo3dv7lmsv5pf4icsy4gepkdorm
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/m4-1.4.18-mkc3u4x2p2wie6jfhuku7g5rkovcrxps
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libxml2-2.9.10-m3l53bhqaaznpmdxzs5jirieu4spdtyq
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/bzip2-1.0.8-fvfpt26p5divvq6344vojyn64enojlui
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/readline-8.0-t54jzdy2jj4snltjazlm3br2urcilc6v
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libtool-2.4.6-jdxbjftheiotj6solpomva7dowrhlerl
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/boost-1.73.0-qzr23mk4jzlnkdfh4mrncz5lvpp67z2r
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/gdbm-1.18.1-4av4gywgpaspkhy3dvbb62nulqogtzbb
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libpciaccess-0.13.5-cmn6yii6vkzjrapeabvbcna3qqqx6web
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/perl-5.30.3-hyrsxn4yox7dp7sywfcs7lbknj45c5pq
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/openssl-1.1.1g-4dj34ywr6ytskzutiwgjrj66sryvav2q
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/autoconf-2.69-nwb3bf5ibencr3coo5kgkxa7tjrj7yfy
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/cmake-3.17.3-thpwguiiywo7hewgnm76t7r6w53mt6cy
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/automake-1.16.2-wdflovn6aocicngqouowxgj3pi3w7uoc
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/glm-0.9.7.1-c3mfw24ivgvgfwwxfia3ipk5lqlxdgcd
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/metis-5.1.0-edcrft4l4szpqji2kowdkzq2ofueh3dr
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/numactl-2.0.12-yvxocdy2kcxvvgatrrst3sqzyt7yxhgn
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/suite-sparse-5.7.2-dgppz4n6wg4b42d4er5zovpefdywbuy3
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/hwloc-1.11.11-ckxpgsn6uuptknjsle5cagqxpbo3b7uc
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/openmpi-3.1.6-wudo6kygednztgzemlnq4l7rlwrwu3zw
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/hdf5-1.10.6-7r2lztqivzy6umgvnhihn4565whablho
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/hypre-2.18.2-dnwivcw3g3kjliygwa536iyaykvjfag6
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/netlib-scalapack-2.1.0-bvapk5ozv46rizqyzb3tlra7jwxkj2ay
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/parmetis-4.0.3-zdxekoefv7fk2qpoyv6xr26622tnosli
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/netcdf-c-4.7.3-uctbd5yydaciec4ircts7prazhmpllj5
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/matio-1.5.13-w3dbllqxjzh3xyc5hexo7jedowsixau5
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/mumps-5.3.3-qb6yumyjj73wcewf4sa4wc2kc5kutswq
==> Installing trilinos
==> Extracting trilinos from binary cache
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/trilinos-12.18.1-j6dav6kowb2c4sfq36vpn7vfhn7es3zf
==> Updating view at /home/spack/spack/var/spack/environments/myproject/.spack-env/view
$ spack find
==> In environment myproject
==> Root specs
tcl   trilinos

==> 37 installed packages
-- linux-ubuntu18.04-x86_64 / gcc@7.5.0 -------------------------
autoconf@2.69	 glm@0.9.7.1	      libtool@2.4.6   netcdf-c@4.7.3	      perl@5.30.3	  xz@5.2.5
automake@1.16.2  hdf5@1.10.6	      libxml2@2.9.10  netlib-scalapack@2.1.0  pkgconf@1.7.3	  zlib@1.2.11
boost@1.73.0	 hwloc@1.11.11	      m4@1.4.18       numactl@2.0.12	      readline@8.0
bzip2@1.0.8	 hypre@2.18.2	      matio@1.5.13    openblas@0.3.10	      suite-sparse@5.7.2
cmake@3.17.3	 libiconv@1.16	      metis@5.1.0     openmpi@3.1.6	      tcl@8.6.8
diffutils@3.7	 libpciaccess@0.13.5  mumps@5.3.3     openssl@1.1.1g	      trilinos@12.18.1
gdbm@1.18.1	 libsigsegv@2.12      ncurses@6.2     parmetis@4.0.3	      util-macros@1.19.1

We’ve installed tcl and trilinos in our environment, along with all of their dependencies. We call tcl and trilinos the roots because we asked for them explicitly. The other 20 packages listed under “installed packages” are present because they were needed as dependencies. So, these are the roots of the packages’ dependency graph.

The “<package> is already installed” messages above are generated because we already installed these packages in previous steps of the tutorial, and we don’t have to rebuild them to put them in an environment.

Using packages

When you install packages into an environment, they are linked into a single prefix, or a view. When you activate the environment with spack env activate, Spack adds subdirectories from the view to PATH, LD_LIBRARY_PATH, CMAKE_PREFIX_PATH and other environment variables. This makes the environment easier to use.

Without environments, you need to spack load or module load a package in order to use it. With environments, you can simply run spack env activate to get everything in the environment on your PATH.

Let’s try it out. myproject is still the active environment, and we just installed tcl. You can see tclsh in your PATH immediately:

$ which tclsh
/home/spack/spack/var/spack/environments/myproject/.spack-env/view/bin/tclsh

And you can run it like you would any other program:

$ tclsh
% echo "hello world!"
hello world!
% exit

Likewise, we installed Trilinos, and you can run some of its sub-programs as well:

$ which algebra
/home/spack/spack/var/spack/environments/myproject/.spack-env/view/bin/algebra
$ algebra

	   AAAAA   LL	     GGGGG   EEEEEEE  BBBBBB   RRRRRR	 AAAAA
	  AA   AA  LL	    GG	 GG  EE       BB   BB  RR   RR	AA   AA
	  AA   AA  LL	    GG	     EE       BB   BB  RR   RR	AA   AA
	  AAAAAAA  LL	    GG	     EEEEE    BBBBBB   RRRRRR	AAAAAAA
	  AA   AA  LL	    GG	GGG  EE       BB   BB  RRRRR	AA   AA
	  AA   AA  LL	    GG	 GG  EE       BB   BB  RR  RR	AA   AA
	  AA   AA  LLLLLLL   GGGGG   EEEEEEE  BBBBBB   RR   RR	AA   AA


			  *** algebra Version 1.47 ***
			       Revised 2019/01/25

			AN ALGEBRAIC MANIPULATION PROGRAM
		 FOR POST-PROCESSING OF FINITE ELEMENT ANALYSES
				EXODUS II VERSION

			  Run on 2020-07-28 at 12:06:08

	       ==== Email gdsjaar@sandia.gov for support ====

			  +++ Copyright 2008 NTESS +++
		       +++ Under the terms of Contract +++
		      +++ DE-NA0003525 with NTESS, the +++
	+++ U.S. Government retains certain rights in this software. +++



 FATAL ERROR - Filenames not specified.

 FATAL ERROR - Syntax is: "algebra file_in file_out"

 PROGRAM ERROR - Dynamic allocation problem - email code sponsor



0LAST ERROR/RETURN CODE:     1

0* * * * * E R R O R   C O D E S * * * * *
0OCCURANCES FLAG  MESSAGE TEXT

	  7   1  SUCCESSFUL COMPLETION
	  0   2  UNABLE TO GET REQUESTED SPACE FROM SYSTEM
	  0   3  DATA MANAGER NOT INITIALIZED
	  0   4  DATA MANAGER WAS PREVIOUSLY INITIALIZED
	 10   5  NAME NOT FOUND IN DICTIONARY
	  0   6  NAME ALREADY EXISTS IN DICTIONARY
	  0   7  ILLEGAL LENGTH REQUEST
	  0   8  UNKNOWN DATA TYPE
	  0   9  DICTIONARY IS FULL
	  0  10  VOID TABLE IS FULL
	  0  11  MEMORY BLOCK TABLE IS FULL
	  0  12  OVERLAPPING VOIDS - INTERNAL ERROR
	  0  13  OVERLAPPING MEMORY BLOCKS - INTERNAL ERROR
	  0  14  INVALID MEMORY BLOCK - EXTENSION LIBRARY ERROR
	  0  15  INVALID ERROR CODE
	  0  16  INVALID INPUT NAME
	  0  17  ILLEGAL CALL WHILE IN DEFERRED MODE
	  0  18  NAME IS OF WRONG TYPE FOR OPERATION


 algebra used 0.01 seconds of CPU time

Uninstalling packages

Now let’s create another project. We’ll call this one myproject2:

$ spack env create myproject2
==> Updating view at /home/spack/spack/var/spack/environments/myproject2/.spack-env/view
==> Created environment 'myproject2' in /home/spack/spack/var/spack/environments/myproject2
==> You can activate this environment with:
==>   spack env activate myproject2
$ spack env activate myproject2
$ spack install hdf5+hl
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libsigsegv-2.12-lbrx7lnfz46ukewxbhxnucmx76g23c6q
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/pkgconf-1.7.3-4sh6pymrm2ms4auu3ajbjjr6fiuhz5g7
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/util-macros-1.19.1-gs6ag7ktdoiirb62t7bcagjw62szrrg2
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libiconv-1.16-jearpk4xci4zc7dkrza4fufaqfkq7rfl
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/xz-5.2.5-6nxes4rhk52rhxj7dntwqa5nzou5sv2t
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/zlib-1.2.11-smoyzzo2qhzpn6mg6rd3l2p7b23enshg
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/m4-1.4.18-mkc3u4x2p2wie6jfhuku7g5rkovcrxps
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/ncurses-6.2-crhlefo3dv7lmsv5pf4icsy4gepkdorm
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libxml2-2.9.10-m3l53bhqaaznpmdxzs5jirieu4spdtyq
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libtool-2.4.6-jdxbjftheiotj6solpomva7dowrhlerl
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/readline-8.0-t54jzdy2jj4snltjazlm3br2urcilc6v
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libpciaccess-0.13.5-cmn6yii6vkzjrapeabvbcna3qqqx6web
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/gdbm-1.18.1-4av4gywgpaspkhy3dvbb62nulqogtzbb
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/perl-5.30.3-hyrsxn4yox7dp7sywfcs7lbknj45c5pq
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/autoconf-2.69-nwb3bf5ibencr3coo5kgkxa7tjrj7yfy
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/automake-1.16.2-wdflovn6aocicngqouowxgj3pi3w7uoc
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/numactl-2.0.12-yvxocdy2kcxvvgatrrst3sqzyt7yxhgn
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/hwloc-1.11.11-ckxpgsn6uuptknjsle5cagqxpbo3b7uc
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/openmpi-3.1.6-wudo6kygednztgzemlnq4l7rlwrwu3zw
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/hdf5-1.10.6-7r2lztqivzy6umgvnhihn4565whablho
==> Updating view at /home/spack/spack/var/spack/environments/myproject2/.spack-env/view
$ spack install trilinos
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libiconv-1.16-jearpk4xci4zc7dkrza4fufaqfkq7rfl
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/zlib-1.2.11-smoyzzo2qhzpn6mg6rd3l2p7b23enshg
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/pkgconf-1.7.3-4sh6pymrm2ms4auu3ajbjjr6fiuhz5g7
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libsigsegv-2.12-lbrx7lnfz46ukewxbhxnucmx76g23c6q
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/util-macros-1.19.1-gs6ag7ktdoiirb62t7bcagjw62szrrg2
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/xz-5.2.5-6nxes4rhk52rhxj7dntwqa5nzou5sv2t
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/openblas-0.3.10-m5gktgohkqi2znlic6cwpz5euhqdle3i
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/diffutils-3.7-otkktenrrvcaf37a7zyeytmjuwsalvtr
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/ncurses-6.2-crhlefo3dv7lmsv5pf4icsy4gepkdorm
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/m4-1.4.18-mkc3u4x2p2wie6jfhuku7g5rkovcrxps
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libxml2-2.9.10-m3l53bhqaaznpmdxzs5jirieu4spdtyq
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/bzip2-1.0.8-fvfpt26p5divvq6344vojyn64enojlui
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/readline-8.0-t54jzdy2jj4snltjazlm3br2urcilc6v
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libtool-2.4.6-jdxbjftheiotj6solpomva7dowrhlerl
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/boost-1.73.0-qzr23mk4jzlnkdfh4mrncz5lvpp67z2r
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/gdbm-1.18.1-4av4gywgpaspkhy3dvbb62nulqogtzbb
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libpciaccess-0.13.5-cmn6yii6vkzjrapeabvbcna3qqqx6web
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/perl-5.30.3-hyrsxn4yox7dp7sywfcs7lbknj45c5pq
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/openssl-1.1.1g-4dj34ywr6ytskzutiwgjrj66sryvav2q
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/autoconf-2.69-nwb3bf5ibencr3coo5kgkxa7tjrj7yfy
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/cmake-3.17.3-thpwguiiywo7hewgnm76t7r6w53mt6cy
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/automake-1.16.2-wdflovn6aocicngqouowxgj3pi3w7uoc
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/glm-0.9.7.1-c3mfw24ivgvgfwwxfia3ipk5lqlxdgcd
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/metis-5.1.0-edcrft4l4szpqji2kowdkzq2ofueh3dr
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/numactl-2.0.12-yvxocdy2kcxvvgatrrst3sqzyt7yxhgn
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/suite-sparse-5.7.2-dgppz4n6wg4b42d4er5zovpefdywbuy3
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/hwloc-1.11.11-ckxpgsn6uuptknjsle5cagqxpbo3b7uc
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/openmpi-3.1.6-wudo6kygednztgzemlnq4l7rlwrwu3zw
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/hypre-2.18.2-dnwivcw3g3kjliygwa536iyaykvjfag6
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/netlib-scalapack-2.1.0-bvapk5ozv46rizqyzb3tlra7jwxkj2ay
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/parmetis-4.0.3-zdxekoefv7fk2qpoyv6xr26622tnosli
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/hdf5-1.10.6-7r2lztqivzy6umgvnhihn4565whablho
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/mumps-5.3.3-qb6yumyjj73wcewf4sa4wc2kc5kutswq
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/netcdf-c-4.7.3-uctbd5yydaciec4ircts7prazhmpllj5
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/matio-1.5.13-w3dbllqxjzh3xyc5hexo7jedowsixau5
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/trilinos-12.18.1-j6dav6kowb2c4sfq36vpn7vfhn7es3zf
==> Updating view at /home/spack/spack/var/spack/environments/myproject2/.spack-env/view
$ spack find
==> In environment myproject2
==> Root specs
hdf5 +hl  trilinos

==> 36 installed packages
-- linux-ubuntu18.04-x86_64 / gcc@7.5.0 -------------------------
autoconf@2.69	 gdbm@1.18.1	libpciaccess@0.13.5  metis@5.1.0	     openblas@0.3.10  readline@8.0
automake@1.16.2  glm@0.9.7.1	libsigsegv@2.12      mumps@5.3.3	     openmpi@3.1.6    suite-sparse@5.7.2
boost@1.73.0	 hdf5@1.10.6	libtool@2.4.6	     ncurses@6.2	     openssl@1.1.1g   trilinos@12.18.1
bzip2@1.0.8	 hwloc@1.11.11	libxml2@2.9.10	     netcdf-c@4.7.3	     parmetis@4.0.3   util-macros@1.19.1
cmake@3.17.3	 hypre@2.18.2	m4@1.4.18	     netlib-scalapack@2.1.0  perl@5.30.3      xz@5.2.5
diffutils@3.7	 libiconv@1.16	matio@1.5.13	     numactl@2.0.12	     pkgconf@1.7.3    zlib@1.2.11

Now we have two environments: one with tcl and trilinos, and another with hdf5 +hl and trilinos. Notice that the roots display exactly as we asked for them on the command line – the hdf5 for this environemnt has an +hl requirement.

We can uninstall trilinos from myproject2 as you would expect:

$ spack uninstall trilinos
y

==> The following packages will be uninstalled:

    -- linux-ubuntu18.04-x86_64 / gcc@7.5.0 -------------------------
    j6dav6k trilinos@12.18.1

==> Do you want to proceed? [y/N] ==> Updating view at /home/spack/spack/var/spack/environments/myproject2/.spack-env/view
$ spack find
==> In environment myproject2
==> Root specs
hdf5 +hl

==> 20 installed packages
-- linux-ubuntu18.04-x86_64 / gcc@7.5.0 -------------------------
autoconf@2.69	 hwloc@1.11.11	      libtool@2.4.6   numactl@2.0.12  readline@8.0
automake@1.16.2  libiconv@1.16	      libxml2@2.9.10  openmpi@3.1.6   util-macros@1.19.1
gdbm@1.18.1	 libpciaccess@0.13.5  m4@1.4.18       perl@5.30.3     xz@5.2.5
hdf5@1.10.6	 libsigsegv@2.12      ncurses@6.2     pkgconf@1.7.3   zlib@1.2.11

Now there is only one root spec, hdf5 +hl, which requires fewer additional dependencies.

However, we still needed trilinos for the myproject environment! What happened to it? Let’s switch back and see.

$ despacktivate
$ spack env activate myproject
$ spack find
==> In environment myproject
==> Root specs
tcl   trilinos

==> 37 installed packages
-- linux-ubuntu18.04-x86_64 / gcc@7.5.0 -------------------------
autoconf@2.69	 glm@0.9.7.1	      libtool@2.4.6   netcdf-c@4.7.3	      perl@5.30.3	  xz@5.2.5
automake@1.16.2  hdf5@1.10.6	      libxml2@2.9.10  netlib-scalapack@2.1.0  pkgconf@1.7.3	  zlib@1.2.11
boost@1.73.0	 hwloc@1.11.11	      m4@1.4.18       numactl@2.0.12	      readline@8.0
bzip2@1.0.8	 hypre@2.18.2	      matio@1.5.13    openblas@0.3.10	      suite-sparse@5.7.2
cmake@3.17.3	 libiconv@1.16	      metis@5.1.0     openmpi@3.1.6	      tcl@8.6.8
diffutils@3.7	 libpciaccess@0.13.5  mumps@5.3.3     openssl@1.1.1g	      trilinos@12.18.1
gdbm@1.18.1	 libsigsegv@2.12      ncurses@6.2     parmetis@4.0.3	      util-macros@1.19.1

Spack is smart enough to realize that trilinos is still present in the other environment. Trilinos won’t actually be uninstalled unless it is no longer needed by any environments or packages. If it is still needed, it is only removed from the environment.

Dealing with Many Specs at Once

In the above examples, we just used install and uninstall. There are other ways to deal with groups of packages, as well.

Adding specs

While we’re still in myproject, let’s add a few specs instead of installing them:

$ spack add hdf5+hl
==> Adding hdf5+hl to environment myproject
==> Updating view at /home/spack/spack/var/spack/environments/myproject/.spack-env/view
$ spack add gmp
==> Adding gmp to environment myproject
==> Updating view at /home/spack/spack/var/spack/environments/myproject/.spack-env/view
$ spack find
==> In environment myproject
==> Root specs
gmp   hdf5 +hl	tcl   trilinos

==> 37 installed packages
-- linux-ubuntu18.04-x86_64 / gcc@7.5.0 -------------------------
autoconf@2.69	 glm@0.9.7.1	      libtool@2.4.6   netcdf-c@4.7.3	      perl@5.30.3	  xz@5.2.5
automake@1.16.2  hdf5@1.10.6	      libxml2@2.9.10  netlib-scalapack@2.1.0  pkgconf@1.7.3	  zlib@1.2.11
boost@1.73.0	 hwloc@1.11.11	      m4@1.4.18       numactl@2.0.12	      readline@8.0
bzip2@1.0.8	 hypre@2.18.2	      matio@1.5.13    openblas@0.3.10	      suite-sparse@5.7.2
cmake@3.17.3	 libiconv@1.16	      metis@5.1.0     openmpi@3.1.6	      tcl@8.6.8
diffutils@3.7	 libpciaccess@0.13.5  mumps@5.3.3     openssl@1.1.1g	      trilinos@12.18.1
gdbm@1.18.1	 libsigsegv@2.12      ncurses@6.2     parmetis@4.0.3	      util-macros@1.19.1

Let’s take a close look at what happened. The two requirements we added, hdf5 +hl and gmp, are present, but they’re not installed in the environment yet. spack add just adds roots to the environment, but it does not automatically install them.

We can install all the as-yet uninstalled packages in an environment by simply running spack install with no arguments:

$ spack install
==> Concretized hdf5+hl
[+]  7r2lztq  hdf5@1.10.6%gcc@7.5.0~cxx~debug~fortran+hl+mpi+pic+shared~szip~threadsafe api=none arch=linux-ubuntu18.04-x86_64
[+]  wudo6ky	  ^openmpi@3.1.6%gcc@7.5.0~atomics~cuda~cxx~cxx_exceptions+gpfs~java~legacylaunchers~memchecker~pmi~sqlite3+static~thread_multiple+vt+wrapper-rpath fabrics=none schedulers=none arch=linux-ubuntu18.04-x86_64
[+]  ckxpgsn	      ^hwloc@1.11.11%gcc@7.5.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml+pci+shared arch=linux-ubuntu18.04-x86_64
[+]  cmn6yii		  ^libpciaccess@0.13.5%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  jdxbjft		      ^libtool@2.4.6%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  mkc3u4x			  ^m4@1.4.18%gcc@7.5.0+sigsegv patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 arch=linux-ubuntu18.04-x86_64
[+]  lbrx7ln			      ^libsigsegv@2.12%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  4sh6pym		      ^pkgconf@1.7.3%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  gs6ag7k		      ^util-macros@1.19.1%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  m3l53bh		  ^libxml2@2.9.10%gcc@7.5.0~python arch=linux-ubuntu18.04-x86_64
[+]  jearpk4		      ^libiconv@1.16%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  6nxes4r		      ^xz@5.2.5%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  smoyzzo		      ^zlib@1.2.11%gcc@7.5.0+optimize+pic+shared arch=linux-ubuntu18.04-x86_64
[+]  yvxocdy		  ^numactl@2.0.12%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  nwb3bf5		      ^autoconf@2.69%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  hyrsxn4			  ^perl@5.30.3%gcc@7.5.0+cpanm+shared+threads arch=linux-ubuntu18.04-x86_64
[+]  4av4gyw			      ^gdbm@1.18.1%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  t54jzdy				  ^readline@8.0%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  crhlefo				      ^ncurses@6.2%gcc@7.5.0~symlinks+termlib arch=linux-ubuntu18.04-x86_64
[+]  wdflovn		      ^automake@1.16.2%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64

==> Concretized gmp
[+]  3ol3tld  gmp@6.1.2%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  nwb3bf5	  ^autoconf@2.69%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  mkc3u4x	      ^m4@1.4.18%gcc@7.5.0+sigsegv patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 arch=linux-ubuntu18.04-x86_64
[+]  lbrx7ln		  ^libsigsegv@2.12%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  hyrsxn4	      ^perl@5.30.3%gcc@7.5.0+cpanm+shared+threads arch=linux-ubuntu18.04-x86_64
[+]  4av4gyw		  ^gdbm@1.18.1%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  t54jzdy		      ^readline@8.0%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  crhlefo			  ^ncurses@6.2%gcc@7.5.0~symlinks+termlib arch=linux-ubuntu18.04-x86_64
[+]  4sh6pym			      ^pkgconf@1.7.3%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  wdflovn	  ^automake@1.16.2%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  jdxbjft	  ^libtool@2.4.6%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64

==> Installing environment myproject
==> Updating view at /home/spack/spack/var/spack/environments/myproject/.spack-env/view

Spack will concretize the new roots, and install everything you added to the environment. Now we can see the installed roots in the output of spack find:

$ spack find
==> In environment myproject
==> Root specs
gmp   hdf5 +hl	tcl   trilinos

==> 38 installed packages
-- linux-ubuntu18.04-x86_64 / gcc@7.5.0 -------------------------
autoconf@2.69	 gmp@6.1.2	      libxml2@2.9.10	      numactl@2.0.12   suite-sparse@5.7.2
automake@1.16.2  hdf5@1.10.6	      m4@1.4.18 	      openblas@0.3.10  tcl@8.6.8
boost@1.73.0	 hwloc@1.11.11	      matio@1.5.13	      openmpi@3.1.6    trilinos@12.18.1
bzip2@1.0.8	 hypre@2.18.2	      metis@5.1.0	      openssl@1.1.1g   util-macros@1.19.1
cmake@3.17.3	 libiconv@1.16	      mumps@5.3.3	      parmetis@4.0.3   xz@5.2.5
diffutils@3.7	 libpciaccess@0.13.5  ncurses@6.2	      perl@5.30.3      zlib@1.2.11
gdbm@1.18.1	 libsigsegv@2.12      netcdf-c@4.7.3	      pkgconf@1.7.3
glm@0.9.7.1	 libtool@2.4.6	      netlib-scalapack@2.1.0  readline@8.0

We can build whole environments this way, by adding specs and installing all at once, or we can install them with the usual install and uninstall portions. The advantage to doing them all at once is that we don’t have to write a script outside of Spack to automate this, and we can kick off a large build of many packages easily.

Configuration

So far, myproject does not have any special configuration associated with it. The specs concretize using Spack’s defaults:

$ spack spec hypre
Input spec
--------------------------------
hypre

Concretized
--------------------------------
hypre@2.18.2%gcc@7.5.0~complex~debug~int64~internal-superlu~mixedint+mpi~openmp+shared~superlu-dist arch=linux-ubuntu18.04-x86_64
    ^openblas@0.3.10%gcc@7.5.0~consistent_fpcsr~ilp64+pic+shared threads=none arch=linux-ubuntu18.04-x86_64
    ^openmpi@3.1.6%gcc@7.5.0~atomics~cuda~cxx~cxx_exceptions+gpfs~java~legacylaunchers~memchecker~pmi~sqlite3+static~thread_multiple+vt+wrapper-rpath fabrics=none schedulers=none arch=linux-ubuntu18.04-x86_64
	^hwloc@1.11.11%gcc@7.5.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml+pci+shared arch=linux-ubuntu18.04-x86_64
	    ^libpciaccess@0.13.5%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
		^libtool@2.4.6%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
		    ^m4@1.4.18%gcc@7.5.0+sigsegv patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 arch=linux-ubuntu18.04-x86_64
			^libsigsegv@2.12%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
		^pkgconf@1.7.3%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
		^util-macros@1.19.1%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
	    ^libxml2@2.9.10%gcc@7.5.0~python arch=linux-ubuntu18.04-x86_64
		^libiconv@1.16%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
		^xz@5.2.5%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
		^zlib@1.2.11%gcc@7.5.0+optimize+pic+shared arch=linux-ubuntu18.04-x86_64
	    ^numactl@2.0.12%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
		^autoconf@2.69%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
		    ^perl@5.30.3%gcc@7.5.0+cpanm+shared+threads arch=linux-ubuntu18.04-x86_64
			^gdbm@1.18.1%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
			    ^readline@8.0%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
				^ncurses@6.2%gcc@7.5.0~symlinks+termlib arch=linux-ubuntu18.04-x86_64
		^automake@1.16.2%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64

You may want to add extra configuration to your environment. You can see how your environment is configured using spack config get:

$ spack config get
# This is a Spack Environment file.
#
# It describes a set of packages to be installed, along with
# configuration settings.
spack:
  # add package specs to the `specs` list
  specs: [tcl, trilinos, hdf5+hl, gmp]
  view: true

It turns out that this is a special configuration format where Spack stores the state for the environment. Currently, the file is just a spack: header and a list of specs. These are the roots.

You can edit this file to add your own custom configuration. Spack provides a shortcut to do that:

spack config edit

You should now see the same file, and edit it to look like this:

# This is a Spack Environment file.
#
# It describes a set of packages to be installed, along with
# configuration settings.
spack:
  packages:
    all:
      providers:
        mpi: [mpich]

  # add package specs to the `specs` list
  specs: [tcl, trilinos, hdf5, gmp]

Now if we run spack spec again in the environment, specs will concretize with mpich as the MPI implementation:

$ spack spec hypre
Input spec
--------------------------------
hypre

Concretized
--------------------------------
hypre@2.18.2%gcc@7.5.0~complex~debug~int64~internal-superlu~mixedint+mpi~openmp+shared~superlu-dist arch=linux-ubuntu18.04-x86_64
    ^mpich@3.3.2%gcc@7.5.0+hwloc+hydra+libxml2+pci+romio~slurm~verbs+wrapperrpath device=ch3 netmod=tcp patches=eb982de3366d48cbc55eb5e0df43373a45d9f51df208abf0835a72dc6c0b4774 pmi=pmi arch=linux-ubuntu18.04-x86_64
	^autoconf@2.69%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
	    ^m4@1.4.18%gcc@7.5.0+sigsegv patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 arch=linux-ubuntu18.04-x86_64
		^libsigsegv@2.12%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
	    ^perl@5.30.3%gcc@7.5.0+cpanm+shared+threads arch=linux-ubuntu18.04-x86_64
		^gdbm@1.18.1%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
		    ^readline@8.0%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
			^ncurses@6.2%gcc@7.5.0~symlinks+termlib arch=linux-ubuntu18.04-x86_64
			    ^pkgconf@1.7.3%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
	^automake@1.16.2%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
	^findutils@4.6.0%gcc@7.5.0 patches=84b916c0bf8c51b7e7b28417692f0ad3e7030d1f3c248ba77c42ede5c1c5d11e,bd9e4e5cc280f9753ae14956c4e4aa17fe7a210f55dd6c84aa60b12d106d47a2 arch=linux-ubuntu18.04-x86_64
	    ^libtool@2.4.6%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
	    ^texinfo@6.5%gcc@7.5.0 patches=12f6edb0c6b270b8c8dba2ce17998c580db01182d871ee32b7b6e4129bd1d23a,1732115f651cff98989cb0215d8f64da5e0f7911ebf0c13b064920f088f2ffe1 arch=linux-ubuntu18.04-x86_64
	^hwloc@2.2.0%gcc@7.5.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml+pci+shared arch=linux-ubuntu18.04-x86_64
	    ^libpciaccess@0.13.5%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
		^util-macros@1.19.1%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
	    ^libxml2@2.9.10%gcc@7.5.0~python arch=linux-ubuntu18.04-x86_64
		^libiconv@1.16%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
		^xz@5.2.5%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
		^zlib@1.2.11%gcc@7.5.0+optimize+pic+shared arch=linux-ubuntu18.04-x86_64
    ^openblas@0.3.10%gcc@7.5.0~consistent_fpcsr~ilp64+pic+shared threads=none arch=linux-ubuntu18.04-x86_64

In addition to the specs section, an environment’s configuration can contain any of the configuration options from Spack’s various config sections. You can add custom repositories, a custom install location, custom compilers, or custom external packages, in addition to the package preferences we show here.

But now we have a problem. We already installed part of this environment with openmpi, but now we want to install it with mpich.

You can run spack concretize inside of an environment to concretize all of its specs. We can run it here:

$ spack concretize -f
==> Concretized tcl
[+]  aszidzn  tcl@8.6.8%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  smoyzzo	  ^zlib@1.2.11%gcc@7.5.0+optimize+pic+shared arch=linux-ubuntu18.04-x86_64

==> Concretized trilinos
[+]  rhmspsu  trilinos@12.18.1%gcc@7.5.0~adios2~alloptpkgs+amesos+amesos2+anasazi+aztec+belos+boost~cgns~chaco~complex~debug~dtk+epetra+epetraext+exodus+explicit_template_instantiation~float+fortran~fortrilinos+glm+gtest+hdf5+hypre+ifpack+ifpack2~intrepid~intrepid2~isorropia+kokkos+matio~mesquite+metis~minitensor+ml+mpi+muelu+mumps+netcdf~nox~openmp~phalanx~piro~pnetcdf~python~rol~rythmos+sacado~shards+shared~shylu~stk~stratimikos+suite-sparse~superlu~superlu-dist~teko~tempus+teuchos+tpetra~x11~xsdkflags~zlib+zoltan+zoltan2 build_type=RelWithDebInfo gotype=long arch=linux-ubuntu18.04-x86_64
[+]  qzr23mk	  ^boost@1.73.0%gcc@7.5.0+atomic+chrono~clanglibcpp~container~context~coroutine+date_time~debug+exception~fiber+filesystem+graph~icu+iostreams+locale+log+math~mpi+multithreaded~numpy~pic+program_options~python+random+regex+serialization+shared+signals~singlethreaded+system~taggedlayout+test+thread+timer~versionedlayout+wave cxxstd=98 patches=246508e052c44b6f4e8c2542a71c06cacaa72cd1447ab8d2a542b987bc35ace9,4dd507e1f5a29e3b87b15321a4d8c74afdc8331433edabf7aeab89b3c405d556 visibility=hidden arch=linux-ubuntu18.04-x86_64
[+]  fvfpt26	      ^bzip2@1.0.8%gcc@7.5.0+shared arch=linux-ubuntu18.04-x86_64
[+]  otkkten		  ^diffutils@3.7%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  jearpk4		      ^libiconv@1.16%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  smoyzzo	      ^zlib@1.2.11%gcc@7.5.0+optimize+pic+shared arch=linux-ubuntu18.04-x86_64
[+]  thpwgui	  ^cmake@3.17.3%gcc@7.5.0~doc+ncurses+openssl+ownlibs~qt arch=linux-ubuntu18.04-x86_64
[+]  crhlefo	      ^ncurses@6.2%gcc@7.5.0~symlinks+termlib arch=linux-ubuntu18.04-x86_64
[+]  4sh6pym		  ^pkgconf@1.7.3%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  4dj34yw	      ^openssl@1.1.1g%gcc@7.5.0+systemcerts arch=linux-ubuntu18.04-x86_64
[+]  hyrsxn4		  ^perl@5.30.3%gcc@7.5.0+cpanm+shared+threads arch=linux-ubuntu18.04-x86_64
[+]  4av4gyw		      ^gdbm@1.18.1%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  t54jzdy			  ^readline@8.0%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  c3mfw24	  ^glm@0.9.7.1%gcc@7.5.0 build_type=RelWithDebInfo arch=linux-ubuntu18.04-x86_64
[+]  znt7mfz	  ^hdf5@1.10.6%gcc@7.5.0~cxx~debug~fortran+hl+mpi+pic+shared~szip~threadsafe api=none arch=linux-ubuntu18.04-x86_64
[+]  qrpxybc	      ^mpich@3.3.2%gcc@7.5.0+hwloc+hydra+libxml2+pci+romio~slurm~verbs+wrapperrpath device=ch3 netmod=tcp patches=eb982de3366d48cbc55eb5e0df43373a45d9f51df208abf0835a72dc6c0b4774 pmi=pmi arch=linux-ubuntu18.04-x86_64
[+]  nwb3bf5		  ^autoconf@2.69%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  mkc3u4x		      ^m4@1.4.18%gcc@7.5.0+sigsegv patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 arch=linux-ubuntu18.04-x86_64
[+]  lbrx7ln			  ^libsigsegv@2.12%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  wdflovn		  ^automake@1.16.2%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  hrv4dx5		  ^findutils@4.6.0%gcc@7.5.0 patches=84b916c0bf8c51b7e7b28417692f0ad3e7030d1f3c248ba77c42ede5c1c5d11e,bd9e4e5cc280f9753ae14956c4e4aa17fe7a210f55dd6c84aa60b12d106d47a2 arch=linux-ubuntu18.04-x86_64
[+]  jdxbjft		      ^libtool@2.4.6%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  cr3i7es		      ^texinfo@6.5%gcc@7.5.0 patches=12f6edb0c6b270b8c8dba2ce17998c580db01182d871ee32b7b6e4129bd1d23a,1732115f651cff98989cb0215d8f64da5e0f7911ebf0c13b064920f088f2ffe1 arch=linux-ubuntu18.04-x86_64
[+]  luexnup		  ^hwloc@2.2.0%gcc@7.5.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml+pci+shared arch=linux-ubuntu18.04-x86_64
[+]  cmn6yii		      ^libpciaccess@0.13.5%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  gs6ag7k			  ^util-macros@1.19.1%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  m3l53bh		      ^libxml2@2.9.10%gcc@7.5.0~python arch=linux-ubuntu18.04-x86_64
[+]  6nxes4r			  ^xz@5.2.5%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  amfr6qp	  ^hypre@2.18.2%gcc@7.5.0~complex~debug~int64~internal-superlu~mixedint+mpi~openmp+shared~superlu-dist arch=linux-ubuntu18.04-x86_64
[+]  m5gktgo	      ^openblas@0.3.10%gcc@7.5.0~consistent_fpcsr~ilp64+pic+shared threads=none arch=linux-ubuntu18.04-x86_64
[+]  w6s7lu2	  ^matio@1.5.13%gcc@7.5.0+hdf5+shared+zlib arch=linux-ubuntu18.04-x86_64
[+]  edcrft4	  ^metis@5.1.0%gcc@7.5.0~gdb~int64~real64+shared build_type=Release patches=4991da938c1d3a1d3dea78e49bbebecba00273f98df2a656e38b83d55b281da1,b1225da886605ea558db7ac08dd8054742ea5afe5ed61ad4d0fe7a495b1270d2 arch=linux-ubuntu18.04-x86_64
[+]  hbvf64o	  ^mumps@5.3.3%gcc@7.5.0+complex+double+float~int64~metis+mpi~parmetis~ptscotch~scotch+shared arch=linux-ubuntu18.04-x86_64
[+]  i6dfzly	      ^netlib-scalapack@2.1.0%gcc@7.5.0~pic+shared build_type=RelWithDebInfo patches=f2baedde688ffe4c20943c334f580eb298e04d6f35c86b90a1f4e8cb7ae344a2 arch=linux-ubuntu18.04-x86_64
[+]  swympwh	  ^netcdf-c@4.7.3%gcc@7.5.0~dap~hdf4~jna+mpi~parallel-netcdf+pic+shared arch=linux-ubuntu18.04-x86_64
[+]  v42khiu	  ^parmetis@4.0.3%gcc@7.5.0~gdb+shared build_type=RelWithDebInfo patches=4f892531eb0a807eb1b82e683a416d3e35154a455274cf9b162fb02054d11a5b,50ed2081bc939269689789942067c58b3e522c269269a430d5d34c00edbc5870,704b84f7c7444d4372cb59cca6e1209df4ef3b033bc4ee3cf50f369bce972a9d arch=linux-ubuntu18.04-x86_64
[+]  dgppz4n	  ^suite-sparse@5.7.2%gcc@7.5.0~cuda~openmp+pic~tbb arch=linux-ubuntu18.04-x86_64

==> Concretized hdf5+hl
[+]  znt7mfz  hdf5@1.10.6%gcc@7.5.0~cxx~debug~fortran+hl+mpi+pic+shared~szip~threadsafe api=none arch=linux-ubuntu18.04-x86_64
[+]  qrpxybc	  ^mpich@3.3.2%gcc@7.5.0+hwloc+hydra+libxml2+pci+romio~slurm~verbs+wrapperrpath device=ch3 netmod=tcp patches=eb982de3366d48cbc55eb5e0df43373a45d9f51df208abf0835a72dc6c0b4774 pmi=pmi arch=linux-ubuntu18.04-x86_64
[+]  nwb3bf5	      ^autoconf@2.69%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  mkc3u4x		  ^m4@1.4.18%gcc@7.5.0+sigsegv patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 arch=linux-ubuntu18.04-x86_64
[+]  lbrx7ln		      ^libsigsegv@2.12%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  hyrsxn4		  ^perl@5.30.3%gcc@7.5.0+cpanm+shared+threads arch=linux-ubuntu18.04-x86_64
[+]  4av4gyw		      ^gdbm@1.18.1%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  t54jzdy			  ^readline@8.0%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  crhlefo			      ^ncurses@6.2%gcc@7.5.0~symlinks+termlib arch=linux-ubuntu18.04-x86_64
[+]  4sh6pym				  ^pkgconf@1.7.3%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  wdflovn	      ^automake@1.16.2%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  hrv4dx5	      ^findutils@4.6.0%gcc@7.5.0 patches=84b916c0bf8c51b7e7b28417692f0ad3e7030d1f3c248ba77c42ede5c1c5d11e,bd9e4e5cc280f9753ae14956c4e4aa17fe7a210f55dd6c84aa60b12d106d47a2 arch=linux-ubuntu18.04-x86_64
[+]  jdxbjft		  ^libtool@2.4.6%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  cr3i7es		  ^texinfo@6.5%gcc@7.5.0 patches=12f6edb0c6b270b8c8dba2ce17998c580db01182d871ee32b7b6e4129bd1d23a,1732115f651cff98989cb0215d8f64da5e0f7911ebf0c13b064920f088f2ffe1 arch=linux-ubuntu18.04-x86_64
[+]  luexnup	      ^hwloc@2.2.0%gcc@7.5.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml+pci+shared arch=linux-ubuntu18.04-x86_64
[+]  cmn6yii		  ^libpciaccess@0.13.5%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  gs6ag7k		      ^util-macros@1.19.1%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  m3l53bh		  ^libxml2@2.9.10%gcc@7.5.0~python arch=linux-ubuntu18.04-x86_64
[+]  jearpk4		      ^libiconv@1.16%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  6nxes4r		      ^xz@5.2.5%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  smoyzzo		      ^zlib@1.2.11%gcc@7.5.0+optimize+pic+shared arch=linux-ubuntu18.04-x86_64

==> Concretized gmp
[+]  3ol3tld  gmp@6.1.2%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  nwb3bf5	  ^autoconf@2.69%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  mkc3u4x	      ^m4@1.4.18%gcc@7.5.0+sigsegv patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 arch=linux-ubuntu18.04-x86_64
[+]  lbrx7ln		  ^libsigsegv@2.12%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  hyrsxn4	      ^perl@5.30.3%gcc@7.5.0+cpanm+shared+threads arch=linux-ubuntu18.04-x86_64
[+]  4av4gyw		  ^gdbm@1.18.1%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  t54jzdy		      ^readline@8.0%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  crhlefo			  ^ncurses@6.2%gcc@7.5.0~symlinks+termlib arch=linux-ubuntu18.04-x86_64
[+]  4sh6pym			      ^pkgconf@1.7.3%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  wdflovn	  ^automake@1.16.2%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  jdxbjft	  ^libtool@2.4.6%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64

==> Updating view at /home/spack/spack/var/spack/environments/myproject/.spack-env/view

Now, all the specs in the environment are concrete and ready to be installed with mpich as the MPI implementation.

Normally, we could just run spack config edit, edit the environment configuration, spack add some specs, and spack install.

But, when we already have installed packages in the environment, we have to force everything in the environment to be re-concretized using spack concretize -f. Then we can re-run spack install.

Building in environments

You’ve already learned about spack dev-build as a way to build a project you’ve already checked out. You can also use environments to set up a development environment. As mentioned, you can use any of the binaries in the environment’s view:

$ spack env status
==> In environment myproject
$ which mpicc
/home/spack/spack/var/spack/environments/myproject/.spack-env/view/bin/mpicc

Spack also sets variables like CPATH, LIBRARY_PATH, and LD_LIBRARY_PATH so that you can easily find headers and libraries in environemnts.

$ env | grep PATH=
LIBRARY_PATH=/home/spack/spack/var/spack/environments/myproject/.spack-env/view/lib:/home/spack/spack/var/spack/environments/myproject/.spack-env/view/lib64
LD_LIBRARY_PATH=/home/spack/spack/var/spack/environments/myproject/.spack-env/view/lib:/home/spack/spack/var/spack/environments/myproject/.spack-env/view/lib64
PKG_CONFIG_PATH=/home/spack/spack/var/spack/environments/myproject/.spack-env/view/lib/pkgconfig:/home/spack/spack/var/spack/environments/myproject/.spack-env/view/lib64/pkgconfig
ACLOCAL_PATH=/home/spack/spack/var/spack/environments/myproject/.spack-env/view/share/aclocal
PATH=/home/spack/spack/var/spack/environments/myproject/.spack-env/view/bin:/home/spack/spack/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
CPATH=/home/spack/spack/var/spack/environments/myproject/.spack-env/view/include
SPACK_LD_LIBRARY_PATH=/home/spack/spack/var/spack/environments/myproject/.spack-env/view/lib:/home/spack/spack/var/spack/environments/myproject/.spack-env/view/lib64
MANPATH=/home/spack/spack/var/spack/environments/myproject/.spack-env/view/share/man:/home/spack/spack/var/spack/environments/myproject/.spack-env/view/man
MODULEPATH=/home/spack/spack/share/spack/modules/linux-ubuntu18.04-x86_64
CMAKE_PREFIX_PATH=/home/spack/spack/var/spack/environments/myproject/.spack-env/view

We can use this to easily build programs. Let’s build a really simple MPI program using this environment. Make a simple test program like this one. Call it mpi-hello.c.

#include <stdio.h>
#include <mpi.h>
#include <zlib.h>

int main(int argc, char **argv) {
  int rank;
  MPI_Init(&argc, &argv);

  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  printf("Hello world from rank %d\n", rank);

  if (rank == 0) {
    printf("zlib version: %s\n", ZLIB_VERSION);
  }

  MPI_Finalize();
}

This program includes a header from zlib, and prints out a message from each MPI rank. It also prints the zlib version.

All you need to do is build and run it:

$ mpicc ./mpi-hello.c
$ mpirun -n 4 ./a.out
Hello world from rank 0
Hello world from rank 1
Hello world from rank 2
Hello world from rank 3
zlib version: 1.2.11

Note that we did not need to pass any special arguments to the compiler; just the source file. This simple example only scratches the surface, but you can use environments to set up dependencies for a project, set up a run environment for a user, support your usual development environment, and many other use cases.

spack.yaml and spack.lock

So far we’ve shown you how to interact with environments from the command line, but they also have a file-based interface that can be used by developers and admins to manage workflows for projects.

In this section we’ll dive a little deeper to see how environments are implemented, and how you could use this in your day-to-day development.

spack.yaml

Earlier, we changed an environment’s configuration using spack config edit. We were actually editing a special file called spack.yaml. Let’s take a look.

We can get directly to the current environment’s location using spack cd:

$ spack cd -e myproject
$ pwd
/home/spack/spack/var/spack/environments/myproject
$ ls
spack.lock  spack.yaml

We notice two things here. First, the environment is just a directory inside of var/spack/environments within the Spack installation. Second, it contains two important files: spack.yaml and spack.lock.

spack.yaml is the configuration file for environments that we’ve already seen, but it does not have to live inside Spack. If you create an environment using spack env create, it is managed by Spack in the var/spack/environments directory, and you can refer to it by name.

You can actually put a spack.yaml file anywhere, and you can use it to bundle an environment, or a list of dependencies to install, with your project. Let’s make a simple project:

$ cd
$ mkdir code
$ cd code
$ spack env create -d .
==> Updating view at /home/spack/code/.spack-env/view
==> Created environment in /home/spack/code
==> You can activate this environment with:
==>   spack env activate /home/spack/code

Here, we made a new directory called code, and we used the -d option to create an environment in it.

What really happened?

$ ls
spack.yaml
$ cat spack.yaml
# This is a Spack Environment file.
#
# It describes a set of packages to be installed, along with
# configuration settings.
spack:
  # add package specs to the `specs` list
  specs: []
  view: true

Spack just created a spack.yaml file in the code directory, with an empty list of root specs. Now we have a Spack environment, in a directory, that we can use to manage dependencies. Suppose your project depends on boost, trilinos, and openmpi. You can add these to your spec list:

# This is a Spack Environment file.
#
# It describes a set of packages to be installed, along with
# configuration settings.
spack:
  # add package specs to the `specs` list
  specs:
  - boost
  - trilinos
  - openmpi

And now anyone who uses the code repository can use this format to install the project’s dependencies. They need only clone the repository, cd into it, and type spack install:

$ spack env activate .
$ spack install
==> Concretized boost
[+]  qzr23mk  boost@1.73.0%gcc@7.5.0+atomic+chrono~clanglibcpp~container~context~coroutine+date_time~debug+exception~fiber+filesystem+graph~icu+iostreams+locale+log+math~mpi+multithreaded~numpy~pic+program_options~python+random+regex+serialization+shared+signals~singlethreaded+system~taggedlayout+test+thread+timer~versionedlayout+wave cxxstd=98 patches=246508e052c44b6f4e8c2542a71c06cacaa72cd1447ab8d2a542b987bc35ace9,4dd507e1f5a29e3b87b15321a4d8c74afdc8331433edabf7aeab89b3c405d556 visibility=hidden arch=linux-ubuntu18.04-x86_64
[+]  fvfpt26	  ^bzip2@1.0.8%gcc@7.5.0+shared arch=linux-ubuntu18.04-x86_64
[+]  otkkten	      ^diffutils@3.7%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  jearpk4		  ^libiconv@1.16%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  smoyzzo	  ^zlib@1.2.11%gcc@7.5.0+optimize+pic+shared arch=linux-ubuntu18.04-x86_64

==> Concretized trilinos
[+]  j6dav6k  trilinos@12.18.1%gcc@7.5.0~adios2~alloptpkgs+amesos+amesos2+anasazi+aztec+belos+boost~cgns~chaco~complex~debug~dtk+epetra+epetraext+exodus+explicit_template_instantiation~float+fortran~fortrilinos+glm+gtest+hdf5+hypre+ifpack+ifpack2~intrepid~intrepid2~isorropia+kokkos+matio~mesquite+metis~minitensor+ml+mpi+muelu+mumps+netcdf~nox~openmp~phalanx~piro~pnetcdf~python~rol~rythmos+sacado~shards+shared~shylu~stk~stratimikos+suite-sparse~superlu~superlu-dist~teko~tempus+teuchos+tpetra~x11~xsdkflags~zlib+zoltan+zoltan2 build_type=RelWithDebInfo gotype=long arch=linux-ubuntu18.04-x86_64
[+]  qzr23mk	  ^boost@1.73.0%gcc@7.5.0+atomic+chrono~clanglibcpp~container~context~coroutine+date_time~debug+exception~fiber+filesystem+graph~icu+iostreams+locale+log+math~mpi+multithreaded~numpy~pic+program_options~python+random+regex+serialization+shared+signals~singlethreaded+system~taggedlayout+test+thread+timer~versionedlayout+wave cxxstd=98 patches=246508e052c44b6f4e8c2542a71c06cacaa72cd1447ab8d2a542b987bc35ace9,4dd507e1f5a29e3b87b15321a4d8c74afdc8331433edabf7aeab89b3c405d556 visibility=hidden arch=linux-ubuntu18.04-x86_64
[+]  fvfpt26	      ^bzip2@1.0.8%gcc@7.5.0+shared arch=linux-ubuntu18.04-x86_64
[+]  otkkten		  ^diffutils@3.7%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  jearpk4		      ^libiconv@1.16%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  smoyzzo	      ^zlib@1.2.11%gcc@7.5.0+optimize+pic+shared arch=linux-ubuntu18.04-x86_64
[+]  thpwgui	  ^cmake@3.17.3%gcc@7.5.0~doc+ncurses+openssl+ownlibs~qt arch=linux-ubuntu18.04-x86_64
[+]  crhlefo	      ^ncurses@6.2%gcc@7.5.0~symlinks+termlib arch=linux-ubuntu18.04-x86_64
[+]  4sh6pym		  ^pkgconf@1.7.3%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  4dj34yw	      ^openssl@1.1.1g%gcc@7.5.0+systemcerts arch=linux-ubuntu18.04-x86_64
[+]  hyrsxn4		  ^perl@5.30.3%gcc@7.5.0+cpanm+shared+threads arch=linux-ubuntu18.04-x86_64
[+]  4av4gyw		      ^gdbm@1.18.1%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  t54jzdy			  ^readline@8.0%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  c3mfw24	  ^glm@0.9.7.1%gcc@7.5.0 build_type=RelWithDebInfo arch=linux-ubuntu18.04-x86_64
[+]  7r2lztq	  ^hdf5@1.10.6%gcc@7.5.0~cxx~debug~fortran+hl+mpi+pic+shared~szip~threadsafe api=none arch=linux-ubuntu18.04-x86_64
[+]  wudo6ky	      ^openmpi@3.1.6%gcc@7.5.0~atomics~cuda~cxx~cxx_exceptions+gpfs~java~legacylaunchers~memchecker~pmi~sqlite3+static~thread_multiple+vt+wrapper-rpath fabrics=none schedulers=none arch=linux-ubuntu18.04-x86_64
[+]  ckxpgsn		  ^hwloc@1.11.11%gcc@7.5.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml+pci+shared arch=linux-ubuntu18.04-x86_64
[+]  cmn6yii		      ^libpciaccess@0.13.5%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  jdxbjft			  ^libtool@2.4.6%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  mkc3u4x			      ^m4@1.4.18%gcc@7.5.0+sigsegv patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 arch=linux-ubuntu18.04-x86_64
[+]  lbrx7ln				  ^libsigsegv@2.12%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  gs6ag7k			  ^util-macros@1.19.1%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  m3l53bh		      ^libxml2@2.9.10%gcc@7.5.0~python arch=linux-ubuntu18.04-x86_64
[+]  6nxes4r			  ^xz@5.2.5%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  yvxocdy		      ^numactl@2.0.12%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  nwb3bf5			  ^autoconf@2.69%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  wdflovn			  ^automake@1.16.2%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  dnwivcw	  ^hypre@2.18.2%gcc@7.5.0~complex~debug~int64~internal-superlu~mixedint+mpi~openmp+shared~superlu-dist arch=linux-ubuntu18.04-x86_64
[+]  m5gktgo	      ^openblas@0.3.10%gcc@7.5.0~consistent_fpcsr~ilp64+pic+shared threads=none arch=linux-ubuntu18.04-x86_64
[+]  w3dbllq	  ^matio@1.5.13%gcc@7.5.0+hdf5+shared+zlib arch=linux-ubuntu18.04-x86_64
[+]  edcrft4	  ^metis@5.1.0%gcc@7.5.0~gdb~int64~real64+shared build_type=Release patches=4991da938c1d3a1d3dea78e49bbebecba00273f98df2a656e38b83d55b281da1,b1225da886605ea558db7ac08dd8054742ea5afe5ed61ad4d0fe7a495b1270d2 arch=linux-ubuntu18.04-x86_64
[+]  qb6yumy	  ^mumps@5.3.3%gcc@7.5.0+complex+double+float~int64~metis+mpi~parmetis~ptscotch~scotch+shared arch=linux-ubuntu18.04-x86_64
[+]  bvapk5o	      ^netlib-scalapack@2.1.0%gcc@7.5.0~pic+shared build_type=RelWithDebInfo patches=f2baedde688ffe4c20943c334f580eb298e04d6f35c86b90a1f4e8cb7ae344a2 arch=linux-ubuntu18.04-x86_64
[+]  uctbd5y	  ^netcdf-c@4.7.3%gcc@7.5.0~dap~hdf4~jna+mpi~parallel-netcdf+pic+shared arch=linux-ubuntu18.04-x86_64
[+]  zdxekoe	  ^parmetis@4.0.3%gcc@7.5.0~gdb+shared build_type=RelWithDebInfo patches=4f892531eb0a807eb1b82e683a416d3e35154a455274cf9b162fb02054d11a5b,50ed2081bc939269689789942067c58b3e522c269269a430d5d34c00edbc5870,704b84f7c7444d4372cb59cca6e1209df4ef3b033bc4ee3cf50f369bce972a9d arch=linux-ubuntu18.04-x86_64
[+]  dgppz4n	  ^suite-sparse@5.7.2%gcc@7.5.0~cuda~openmp+pic~tbb arch=linux-ubuntu18.04-x86_64

==> Concretized openmpi
[+]  wudo6ky  openmpi@3.1.6%gcc@7.5.0~atomics~cuda~cxx~cxx_exceptions+gpfs~java~legacylaunchers~memchecker~pmi~sqlite3+static~thread_multiple+vt+wrapper-rpath fabrics=none schedulers=none arch=linux-ubuntu18.04-x86_64
[+]  ckxpgsn	  ^hwloc@1.11.11%gcc@7.5.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml+pci+shared arch=linux-ubuntu18.04-x86_64
[+]  cmn6yii	      ^libpciaccess@0.13.5%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  jdxbjft		  ^libtool@2.4.6%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  mkc3u4x		      ^m4@1.4.18%gcc@7.5.0+sigsegv patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 arch=linux-ubuntu18.04-x86_64
[+]  lbrx7ln			  ^libsigsegv@2.12%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  4sh6pym		  ^pkgconf@1.7.3%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  gs6ag7k		  ^util-macros@1.19.1%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  m3l53bh	      ^libxml2@2.9.10%gcc@7.5.0~python arch=linux-ubuntu18.04-x86_64
[+]  jearpk4		  ^libiconv@1.16%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  6nxes4r		  ^xz@5.2.5%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  smoyzzo		  ^zlib@1.2.11%gcc@7.5.0+optimize+pic+shared arch=linux-ubuntu18.04-x86_64
[+]  yvxocdy	      ^numactl@2.0.12%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  nwb3bf5		  ^autoconf@2.69%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  hyrsxn4		      ^perl@5.30.3%gcc@7.5.0+cpanm+shared+threads arch=linux-ubuntu18.04-x86_64
[+]  4av4gyw			  ^gdbm@1.18.1%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  t54jzdy			      ^readline@8.0%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
[+]  crhlefo				  ^ncurses@6.2%gcc@7.5.0~symlinks+termlib arch=linux-ubuntu18.04-x86_64
[+]  wdflovn		  ^automake@1.16.2%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64

==> Installing environment /home/spack/code
==> Updating view at /home/spack/code/.spack-env/view

Spack concretizes the specs in the spack.yaml file and installs them.

What happened here? If you cd into a directory that has a spack.yaml file in it, Spack considers this directory’s environment to be activated. The directory does not have to live within Spack; it can be anywhere.

So, from ~/code, we can actually manipulate spack.yaml using spack add and spack remove (just like managed environments):

$ spack add hdf5@5.5.1
==> Adding hdf5@5.5.1 to environment /home/spack/code
==> Updating view at /home/spack/code/.spack-env/view
$ cat spack.yaml
# This is a Spack Environment file.
#
# It describes a set of packages to be installed, along with
# configuration settings.
spack:
  # add package specs to the `specs` list
  specs: [boost, trilinos, openmpi, hdf5@5.5.1]
  view: true
$ spack remove hdf5
==> Removing hdf5 from environment /home/spack/code
==> Updating view at /home/spack/code/.spack-env/view

spack.lock

Okay, we’ve covered managed environments, environments in directories, and the last thing we’ll cover is spack.lock. You may remember that when we ran spack install, Spack concretized all the specs in the spack.yaml file and installed them.

Whenever we concretize Specs in an environment, all concrete specs in the environment are written out to a spack.lock file alongside spack.yaml. The spack.lock file is not really human-readable like the spack.yaml file. It is a json format that contains all the information that we need to reproduce the build of an environment:

$ head -30 spack.lock
{
 "_meta": {
  "file-type": "spack-lockfile",
  "lockfile-version": 2
 },
 "roots": [
  {
   "hash": "cspsw4ijcdfonvmibeld54hp6covw2if",
   "spec": "boost"
  },
  {
   "hash": "uqdfygm4nzcgw3b4k4vpg4kwogrq2o2z",
   "spec": "trilinos"
  },
  {
   "hash": "vseiegeewfblj7sxn5nctaucw2wwdu5t",
   "spec": "openmpi"
  }
 ],
 "concrete_specs": {
  "cspsw4ijcdfonvmibeld54hp6covw2if": {
   "boost": {
    "version": "1.73.0",
    "arch": {
     "platform": "linux",
     "platform_os": "ubuntu18.04",
     "target": "x86_64"
    },
    "compiler": {
     "name": "gcc",

spack.yaml and spack.lock correspond to two fundamental concepts in Spack, but for environments:

  • spack.yaml is the set of abstract specs and configuration that you want to install.

  • spack.lock is the set of all fully concretized specs generated from concretizing spack.yaml

Using either of these, you can recreate an environment that someone else built. spack env create takes an extra optional argument, which can be either a spack.yaml or a spack.lock file:

$ spack env create abstract spack.yaml
==> Updating view at /home/spack/spack/var/spack/environments/abstract/.spack-env/view
==> Created environment 'abstract' in /home/spack/spack/var/spack/environments/abstract
==> You can activate this environment with:
==>   spack env activate abstract
$ spack env create concrete spack.lock
==> Updating view at /home/spack/spack/var/spack/environments/concrete/.spack-env/view
==> Created environment 'concrete' in /home/spack/spack/var/spack/environments/concrete
==> You can activate this environment with:
==>   spack env activate concrete

Both of these create a new environment from the old one, but which one you choose to use depends on your needs:

  1. abstract: copying the yaml file allows someone else to build your requirements, potentially a different way.

  2. concrete: copying the lock file allows someone else to rebuild your installation exactly as you built it.

The first use case can re-concretize the same specs on new platforms in order to build, but it will preserve the abstract requirements. The second use case (currently) requires you to be on the same machine, but it retains all decisions made during concretization and is faithful to a prior install.