Getting Started¶
Getting Spack is easy. You can clone it from the GitHub repository using this command:
$ git clone --depth=2 https://github.com/spack/spack.git
This will create a directory called spack.
Once you have cloned Spack, we recommend sourcing the appropriate script for your shell.
For bash, zsh and sh users:
$ . spack/share/spack/setup-env.sh
For csh and tcsh users:
$ source spack/share/spack/setup-env.csh
For fish users:
$ . spack/share/spack/setup-env.fish
Now you’re ready to use Spack!
List packages you can install¶
Once Spack is ready, you can list all the packages it knows about with the following command:
$ spack list
If you want to get more information on a specific package, for instance hdf5, you can use:
$ spack info hdf5
This command shows information about hdf5, including a brief description, the versions of the package Spack knows about, and all the options you can activate when installing.
As you can see, it’s quite simple to gather basic information on packages before you install them!
Slowdown on the very first command
The first command you run with Spack may take a while, as Spack builds caches to speed up future commands.
Installing your first package¶
To install most packages, Spack needs a compiler suite to be available. To search your machine for available compilers, you can run:
$ spack compiler find
The command shows users whether any compilers were found and where their configuration is stored. If the search was successful, you can now list known compilers, and get an output similar to the following:
$ spack compiler list
==> Available compilers
-- gcc ubuntu20.04-x86_64 ---------------------------------------
[e] gcc@9.4.0 [e] gcc@8.4.0 [e] gcc@10.5.0
If no compilers were found, you need to either:
Install further prerequisites, see Spack Prerequisites, and repeat the search above.
Register a build cache that provides a compiler already available as a binary
Once a compiler is available, you can proceed installing your first package:
$ spack install tcl
The output of this command should look similar to the following:
[e] zmjbkxx gcc@10.5.0 /usr (0s)
[e] rawvy4p glibc@2.31 /usr (0s)
[+] 5qfbgng compiler-wrapper@1.0 /home/spack/.local/spack/opt/linux-icelake/compiler-wrapper-1.0-5qfbgngzoqcjfbwrjn2vh75fr3g25c35 (0s)
[+] vchaib2 gcc-runtime@10.5.0 /home/spack/.local/spack/opt/linux-icelake/gcc-runtime-10.5.0-vchaib2njqlk2cud4a2n33tabq526qjj (0s)
[+] vzazvty gmake@4.4.1 /home/spack/.local/spack/opt/linux-icelake/gmake-4.4.1-vzazvtyn5cjdmg3vkkuau35x7hzu7pyl (12s)
[+] soedrhb zlib-ng@2.3.3 /home/spack/.local/spack/opt/linux-icelake/zlib-ng-2.3.3-soedrhbnpeordiixaib6utcple6tpgya (3s)
[+] u6nztpk tcl@8.6.17 /home/spack/.local/spack/opt/linux-icelake/tcl-8.6.17-u6nztpkhzbga4ul665qqhxucxqk3cins (49s)
Congratulations! You just installed your first package with Spack!
Use the software you just installed¶
Once you have installed tcl, you can immediately use it by starting the tclsh with its absolute path:
$ /home/spack/.local/spack/opt/linux-icelake/tcl-8.6.17-u6nztpkhzbga4ul665qqhxucxqk3cins/bin/tclsh
>% echo "Hello world!"
Hello world!
This works, but using such a long absolute path is not the most convenient way to run an executable.
The simplest way to have tclsh available on the command line is:
$ spack load tcl
The environment of the current shell has now been modified, and you can run
$ tclsh
directly. To undo these modifications, you can:
$ spack unload tcl
Environments and views
Spack Environments are a better way to install and load a set of packages that are frequently used together.
The discussion of this topic goes beyond this Getting Started guide, and we refer to Environments (spack.yaml, spack.lock) for more information.
Next steps¶
This section helped you get Spack installed and running quickly. There are further resources in the documentation that cover both basic and advanced topics in more detail: