WIP: "spack uninstall": don't modify env#26766
WIP: "spack uninstall": don't modify env#26766scheibelp wants to merge 23 commits intospack:developfrom
Conversation
…e environment: to update the spack.yaml you must call 'spack rm'.
|
Only read the title, but this sounds good! |
| if env: | ||
| env.regenerate_views() |
There was a problem hiding this comment.
Notice that elsewhere we do:
with self.write_transaction():
self.regenerate_views()
.. I'd be a fan not to use write_transaction, because it has the side-effect of deserializing the environment from disk, even if the in-memory representation is newer, making environments hard to use as in-memory objects in scripts where you don't need to store a spack.yaml (#25532)
There was a problem hiding this comment.
not to use write_transaction, because it has the side-effect of deserializing the environment from disk
I'm not sure what you mean here: a write transaction takes a lock on the file - AFAIK it is the only way to ensure that the disk and in-memory representation are in sync (which I think is the opposite of what you are saying).
making environments hard to use as in-memory objects in scripts where you don't need to store a spack.yaml
This could be handled by either (a) do all your modifications inside of transactions (if you are interacting with disk) or (b) do none of them inside transactions. I think (a) is safer because I don't know if our API guarantees not using transactions (perhaps that is covered in #25532)
…no-add' option with an '--add' flag (which enables the old behavior)
…the env, but is not concrete, so is not found)
…(intermediate work)
|
Can't wait for this to be merged. |
| if $list_options | ||
| then | ||
| SPACK_COMPREPLY="-h --help --only -u --until -j --jobs --reuse --overwrite --fail-fast --keep-prefix --keep-stage --dont-restage --use-cache --no-cache --cache-only --monitor --monitor-save-local --monitor-tags --monitor-keep-going --monitor-host --monitor-prefix --include-build-deps --no-check-signature --require-full-hash-match --show-log-on-error --source -n --no-checksum --deprecated -v --verbose --fake --only-concrete --no-add -f --file --clean --dirty --test --run-tests --log-format --log-file --help-cdash --cdash-upload-url --cdash-build --cdash-site --cdash-track --cdash-buildstamp -y --yes-to-all" | ||
| SPACK_COMPREPLY="-h --help --only -u --until -j --jobs --reuse --overwrite --fail-fast --keep-prefix --keep-stage --dont-restage --use-cache --no-cache --cache-only --monitor --monitor-save-local --monitor-tags --monitor-keep-going --monitor-host --monitor-prefix --include-build-deps --no-check-signature --require-full-hash-match --show-log-on-error --source -n --no-checksum --deprecated -v --verbose --fake --only-concrete --add -f --file --clean --dirty --test --run-tests --log-format --log-file --help-cdash --cdash-upload-url --cdash-build --cdash-site --cdash-track --cdash-buildstamp -y --yes-to-all" |
There was a problem hiding this comment.
We should keep the --no-add flag so that people who are already using it don't have their scripts broken (it's just overspecified for the default behavior now).
| msg = ('You asked to install {0}, which is not in ' | ||
| 'the current environment, but did not also ' | ||
| 'specify --add'.format(abstract.name)) |
There was a problem hiding this comment.
I think this could be clearer. Maybe
"Cannot install '{0}' because it is not in the current environment. You can add it to the environment with 'spack add {0}', or as part of the install command with 'spack install --add {0}'.format(abstract)
| # one or more of the specs to be uninstalled. There may also be | ||
| # packages in those envs which depend on the base set of packages | ||
| # to uninstall, but this covers that scenario. | ||
| or (not args.remove and spec_to_other_envs) |
There was a problem hiding this comment.
We should still display this message even if the removal portion will work, since the uninstall portion will not
|
Superseded by #33711. |
|
This was merged as #33711. |
Currently if you run
spack uninstall xin an environment, andxrefers to a user spec (e.g. something added withspack add), Spack will update thespack.yamlto remove that spec. This changes the behavior so thatspack uninstalljust uninstalls the spec: if you immediately runspack installin the environment (which in Spack is a request to install all specs registered with the environment), then - with this PR - it would reinstall the spec.This is anticipated to be useful if a user is modifying the package.py for a package in their environment: they may want to uninstall and then reinstall it to get the latest state (at the moment, modifications to the package.py don't affect the hash that Spack uses to compute the install prefix and thereby to distinguish it from other installed specs).
spack rmcan already remove specs, so there is still a command line mechanism available to edit the environment.This could interfere with scripts that depend on the current behavior of
spack uninstall, although I consider that unlikely since this I don't think users would generally script uninstall actions.If you have environments
e1ande2, and specs [X, Y] such that [X, Y] is ine1, and [X] is ine2spack uninstall yine1: uninstalls the spec (but with this PR it stays in e1)spack uninstall xine1: complains becausexis also ine2spack uninstall --remove xine1: removesxfrome1but does not actually uninstall the specspack uninstall -f xine1: uninstalls the spec (both e1 and e2 are now "missing" this spec)If you have environments e1 and e2, and specs [P, Q, R] such that
P->R,Q->R, and [P, R] are in e1 and [Q, R] are in e2spack uninstall pine1: uninstalls the specspack uninstall rine1: will fail for two reasons: (1) P needs R in e1 and (2) e2 needs Rspack uninstall --dependents rine1: will fail becausee2needs Rspack uninstall --dependents --remove rine1: removes R frome1(but does not uninstall it) and uninstalls (and removes) Pspack uninstall -f --dependents rine1: will uninstall P, Q, and R (i.e. e2 will have dependent specs uninstalled as a side effect)spack uninstall -f --dependents --remove rine1: this uninstalls P, Q, and R, and removes [P, R] frome1spack uninstall -f --remove rine1: uninstalls R (so it is "missing" in both environments) and removes R frome1(note thate1would still install R as a dependency of P, but it would no longer be listed as a root spec)(This is now handled)
This PR does not remove the complementary behavior fromspack install: if a user runsspack install xin an environment, it will addxto the list of user specs recorded for the environment. This could easily be removed, although I think this behavior could be useful: without this, if you want to install a new spec to an environment, you would have to runspack add xfollowed byspack install.spack installhas also been updated: by default it will not modify an environment unless you specify--add(previously, you had to specify--no-addto prevent Spack from updating the current active environment).Other notes:
spack uninstall -fa spec that is wanted by existing environments, their corresponding views are not updated (this was the case before, I'm just noting that explicitly here).TODOs:
spack installso that it doesn't modify the active environment by default--addand--removeoptions tospack installandspack uninstall, respectively