Uninstalling Packages
You can uninstall packages using spack uninstall
command. There are different cases you may face
while uninstalling packages. For example, you may have different configurations of the same version of a package.
The following sub-sections will explore those forms and show how to uninstall packages in each form.
To get more details you can refer to Spack Documentation.
One Spec of a Package
If you’ve installed a package using only one spec, then you can simply uninstall that package as follows:
spack uninstall [options] <package_name>
shell
The following table shows the most common options that can be used with the spack uninstall
command.
Flag | Description | |
---|---|---|
-f |
remove regardless of whether other packages or environments depend on this one |
|
-R |
uninstall any packages that depend on the ones given via command line |
|
-a |
remove all installed packages that match each supplied spec |
For example, if you show the currently installed packages using spack find
command you get the following output:
==> 63 installed packages -- linux-centos7-x86_64 / gcc@4.8.5 ----------------------------- autoconf@2.69 gdbm@1.18.1 libtool@2.4.6 perl@5.32.0 zlib@1.2.11 automake@1.16.2 gmp@6.1.2 m4@1.4.18 pkgconf@1.7.3 berkeley-db@18.1.40 isl@0.20 mpc@1.1.0 readline@8.0 diffutils@3.7 libiconv@1.16 mpfr@3.1.6 tcl@8.6.10 ...
shell
The output shows that the tcl
package was installed once with only one spec. In this case, you can uninstall it by simply typing:
spack uninstall tcl
shell
Sometimes when you try to uninstall a package that’s dependent on other packages, you get an error that prevents you from uninstalling the package.
For example, the tcl
package depends on the zlib
package.
If you try to uninstall zlib
, you get the following error:
==> Will not uninstall zlib@1.2.11%gcc@4.8.5/64vg6e4 The following packages depend on it: -- linux-centos7-x86_64 / gcc@4.8.5 ----------------------------- vxq35mm gcc@9.3.0 3vbkxar tcl@8.6.10 ==> Error: There are still dependents. use `spack uninstall --dependents` to remove dependents too
shell
If you would like to uninstall zlib
regardless of whether other packages or environments depend on it, you type:
spack uninstall -f zlib
shell
zlib
will be uninstalled even if there are some other packages depend on it.
If you would like to uninstall zlib
and its dependents, you type:
spack uninstall -R zlib
shell
This command removes zlib
and all packages depend on it (gcc@9.3.0
and tcl@8.6.10
).
You can uninstall a package that was installed using different specs. For example, zlib
has been installed using different specs.
To show the installed versions of zlib
, type:
spack find zlib
shell
The following output shows that 5 versions of zlib
have been installed. If you try to uninstall zlib
using its name you get an error.
spack uninstall zlib
shell
Output:
==> Error: zlib matches multiple packages: -- linux-centos7-x86_64 / gcc@4.8.5 ----------------------------- ss3zkvn zlib@1.2.8 64vg6e4 zlib@1.2.11 -- linux-centos7-x86_64 / gcc@9.3.0 ----------------------------- 7hnjrwi zlib@1.2.8 o5eyrr4 zlib@1.2.11 oodul3l zlib@1.2.11 ==> Error: You can either: a) use a more specific spec, or b) specify the spec by its hash (e.g. `spack uninstall /hash`), or c) use `spack uninstall --all` to uninstall ALL matching specs.
shell
If you want to uninstall all installed versions of zlib
, you can use the -a
option as follows:
spack uninstall -a zlib
shell
If you would like to uninstall a specific version of the installed versions of zlib
, you can do so by using the hash of that version.
This will be shown that in the following sections.
Different Versions with Different Specs
Suppose you have installed a package with different versions where each version was installed using a different spec.
For instance, you can show the installed version of tcl
as follows:
spack find tcl
shell
Output:
==> 2 installed packages -- linux-centos7-x86_64 / gcc@4.8.5 ----------------------------- tcl@8.6.10 -- linux-centos7-x86_64 / gcc@9.3.0 ----------------------------- tcl@8.5.19
shell
The output shows that two versions of tcl
have been installed (tcl@8.6.10
and tcl@8.5.19
). You won’t be able to uninstall any of them using the package_name.
spack uninstall tcl
shell
Output:
==> Error: tcl matches multiple packages: -- linux-centos7-x86_64 / gcc@4.8.5 ----------------------------- 3vbkxar tcl@8.6.10 -- linux-centos7-x86_64 / gcc@9.3.0 ----------------------------- 7qka2cb tcl@8.5.19 ==> Error: You can either: a) use a more specific spec, or b) specify the spec by its hash (e.g. `spack uninstall /hash`), or c) use `spack uninstall --all` to uninstall ALL matching specs.
shell
In this case, you can use the hashes of the installed packages. To show the hashes of tcl
, type:
spack find -l tcl
shell
The following output shows that two versions of tcl
have been installed along with their hashes.
==> 2 installed packages -- linux-centos7-x86_64 / gcc@4.8.5 ----------------------------- 3vbkxar tcl@8.6.10 -- linux-centos7-x86_64 / gcc@9.3.0 ----------------------------- 7qka2cb tcl@8.5.19
shell
You can uninstall any of the installed packages using its hash. To uninstall tcl@8.5.19
, you can use its hash 7qka2cb
as follows:
spack uninstall /7qka2cb
uninstall
You will be asked if you want to proceed. You type Y and the package will be uninstalled.
==> The following packages will be uninstalled: -- linux-centos7-x86_64 / gcc@9.3.0 ----------------------------- 7qka2cb tcl@8.5.19 ==> Do you want to proceed? [y/N] y ==> Successfully uninstalled tcl@8.5.19%gcc@9.3.0 arch=linux-centos7-x86_64/7qka2cb
shell
It’s recommended to using the hash to uninstall packages to avoid any confusion. |