diff options
author | Alec Scott <hi@alecbcs.com> | 2024-11-08 03:16:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-08 00:16:01 -0800 |
commit | ff26d2f8331c900123f6659f762e0cfa1aba47e2 (patch) | |
tree | 691e04554ce48d50fce2e6134b68493180c243d4 /share | |
parent | ed916ffe6ce9bd6af94cbd4538b06f258a8d766c (diff) | |
download | spack-ff26d2f8331c900123f6659f762e0cfa1aba47e2.tar.gz spack-ff26d2f8331c900123f6659f762e0cfa1aba47e2.tar.bz2 spack-ff26d2f8331c900123f6659f762e0cfa1aba47e2.tar.xz spack-ff26d2f8331c900123f6659f762e0cfa1aba47e2.zip |
`spack env track` command (#41897)
This PR adds a sub-command to `spack env` (`track`) which allows users to add/link
anonymous environments into their installation as named environments. This allows
users to more easily track their installed packages and the environments they're
dependencies of. For example, with the addition of #41731 it's now easier to remove
all packages not required by any environments with,
```
spack gc -bE
```
#### Usage
```
spack env track /path/to/env
==> Linked environment in /path/to/env
==> You can activate this environment with:
==> spack env activate env
```
By default `track /path/to/env` will use the last directory in the path as the name of
the environment. However users may customize the name of the linked environment
with `-n | --name`. Shown below.
```
spack env track /path/to/env --name foo
==> Tracking environment in /path/to/env
==> You can activate this environment with:
==> spack env activate foo
```
When removing a linked environment, Spack will remove the link to the environment
but will keep the structure of the environment within the directory. This will allow
users to remove a linked environment from their installation without deleting it from
a shared repository.
There is a `spack env untrack` command that can be used to *only* untrack a tracked
environment -- it will fail if it is used on a managed environment. Users can also use
`spack env remove` to untrack an environment.
This allows users to continue to share environments in git repositories while also having
the dependencies of those environments be remembered by Spack.
---------
Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
Diffstat (limited to 'share')
-rw-r--r-- | share/spack/spack-completion.bash | 20 | ||||
-rw-r--r-- | share/spack/spack-completion.fish | 22 |
2 files changed, 41 insertions, 1 deletions
diff --git a/share/spack/spack-completion.bash b/share/spack/spack-completion.bash index d8c58143c9..8946bf1dcc 100644 --- a/share/spack/spack-completion.bash +++ b/share/spack/spack-completion.bash @@ -1023,7 +1023,7 @@ _spack_env() { then SPACK_COMPREPLY="-h --help" else - SPACK_COMPREPLY="activate deactivate create remove rm rename mv list ls status st loads view update revert depfile" + SPACK_COMPREPLY="activate deactivate create remove rm rename mv list ls status st loads view update revert depfile track untrack" fi } @@ -1141,6 +1141,24 @@ _spack_env_depfile() { fi } +_spack_env_track() { + if $list_options + then + SPACK_COMPREPLY="-h --help -n --name -y --yes-to-all" + else + SPACK_COMPREPLY="" + fi +} + +_spack_env_untrack() { + if $list_options + then + SPACK_COMPREPLY="-h --help -f --force -y --yes-to-all" + else + _environments + fi +} + _spack_extensions() { if $list_options then diff --git a/share/spack/spack-completion.fish b/share/spack/spack-completion.fish index afea0b1a57..17b7cd42e4 100644 --- a/share/spack/spack-completion.fish +++ b/share/spack/spack-completion.fish @@ -1488,6 +1488,8 @@ complete -c spack -n '__fish_spack_using_command_pos 0 env' -f -a view -d 'manag complete -c spack -n '__fish_spack_using_command_pos 0 env' -f -a update -d 'update the environment manifest to the latest schema format' complete -c spack -n '__fish_spack_using_command_pos 0 env' -f -a revert -d 'restore the environment manifest to its previous format' complete -c spack -n '__fish_spack_using_command_pos 0 env' -f -a depfile -d 'generate a depfile to exploit parallel builds across specs' +complete -c spack -n '__fish_spack_using_command_pos 0 env' -f -a track -d 'track an environment from a directory in Spack' +complete -c spack -n '__fish_spack_using_command_pos 0 env' -f -a untrack -d 'track an environment from a directory in Spack' complete -c spack -n '__fish_spack_using_command env' -s h -l help -f -a help complete -c spack -n '__fish_spack_using_command env' -s h -l help -d 'show this help message and exit' @@ -1669,6 +1671,26 @@ complete -c spack -n '__fish_spack_using_command env depfile' -s o -l output -r complete -c spack -n '__fish_spack_using_command env depfile' -s G -l generator -r -f -a make complete -c spack -n '__fish_spack_using_command env depfile' -s G -l generator -r -d 'specify the depfile type (only supports `make`)' +# spack env track +set -g __fish_spack_optspecs_spack_env_track h/help n/name= y/yes-to-all +complete -c spack -n '__fish_spack_using_command_pos 0 env track' -f -a '(__fish_spack_environments)' +complete -c spack -n '__fish_spack_using_command env track' -s h -l help -f -a help +complete -c spack -n '__fish_spack_using_command env track' -s h -l help -d 'show this help message and exit' +complete -c spack -n '__fish_spack_using_command env track' -s n -l name -r -f -a name +complete -c spack -n '__fish_spack_using_command env track' -s n -l name -r -d 'custom environment name' +complete -c spack -n '__fish_spack_using_command env track' -s y -l yes-to-all -f -a yes_to_all +complete -c spack -n '__fish_spack_using_command env track' -s y -l yes-to-all -d 'assume "yes" is the answer to every confirmation request' + +# spack env untrack +set -g __fish_spack_optspecs_spack_env_untrack h/help f/force y/yes-to-all +complete -c spack -n '__fish_spack_using_command_pos_remainder 0 env untrack' -f -a '(__fish_spack_environments)' +complete -c spack -n '__fish_spack_using_command env untrack' -s h -l help -f -a help +complete -c spack -n '__fish_spack_using_command env untrack' -s h -l help -d 'show this help message and exit' +complete -c spack -n '__fish_spack_using_command env untrack' -s f -l force -f -a force +complete -c spack -n '__fish_spack_using_command env untrack' -s f -l force -d 'force unlink even when environment is active' +complete -c spack -n '__fish_spack_using_command env untrack' -s y -l yes-to-all -f -a yes_to_all +complete -c spack -n '__fish_spack_using_command env untrack' -s y -l yes-to-all -d 'assume "yes" is the answer to every confirmation request' + # spack extensions set -g __fish_spack_optspecs_spack_extensions h/help l/long L/very-long d/deps p/paths s/show= complete -c spack -n '__fish_spack_using_command_pos_remainder 0 extensions' -f -a '(__fish_spack_extensions)' |