Repository: spack/spack

Issue:
`spack uninstall -f` is broken
@alalazo  It looks like PR #670 might have broken "spack uninstall -f".  Can you please look into it?

```
[me@ankeli icebin]$ spack uninstall -f openblas
==> The following packages will be uninstalled : 


==> Do you want to proceed ? [y/n]
y
[me@ankeli icebin]$ ls /home/rpfische/spack/opt/spack/linux-x86_64/gcc-4.9.3/openblas-0.2.17-lvi5fks7zompzclvc2lyzwilfefal4ld/lib
blas.a  cmake  libblas.a  liblapack.a  libopenblas.a  libopenblas_nehalemp-r0.2.17.a
```

`spack uninstall -f` is broken
@alalazo  It looks like PR #670 might have broken "spack uninstall -f".  Can you please look into it?

```
[me@ankeli icebin]$ spack uninstall -f openblas
==> The following packages will be uninstalled : 


==> Do you want to proceed ? [y/n]
y
[me@ankeli icebin]$ ls /home/rpfische/spack/opt/spack/linux-x86_64/gcc-4.9.3/openblas-0.2.17-lvi5fks7zompzclvc2lyzwilfefal4ld/lib
blas.a  cmake  libblas.a  liblapack.a  libopenblas.a  libopenblas_nehalemp-r0.2.17.a
```



Discussion:
Sure.

##### TLDR

I cannot reproduce the problem, so it's hard for me to look into that with a debugger. From the output you posted it seems that your query `openblas` didn't produce any matching installed specs. At first glance this may be due to one of these two calls gone wrong  :

``` python
specs = spack.cmd.parse_specs(args.packages)
uninstall_list = concretize_specs(specs, args.all, args.force)
...
```

The second one involves a query to the db, so... can you re-try after a `spack reindex` to see if this solves the issue?

##### Details

Output I get when trying to uninstall a package **associated with multiple installed specs**:

``` bash
$ spack uninstall -f  szip
==> Error: szip matches multiple packages:

-- production / clang@3.8.0 -------------------------------------
uldzrgd szip@2.1

-- production / gcc@4.8 -----------------------------------------
35xe6vt szip@2.1

-- production / gcc@5.3.0 ---------------------------------------
a3rdlo5 szip@2.1

==> Error: You can either:
    a) Use a more specific spec, or
    b) use spack uninstall -a to uninstall ALL matching specs.
```

Output I get when trying to uninstall a package **associated with a single installed spec**:

``` bash
$ spack uninstall -f  szip%clang
==> The following packages will be uninstalled : 

-- production / clang@3.8.0 -------------------------------------
uldzrgd szip@2.1

==> Do you want to proceed ? [y/n]
```

Output I get when trying to uninstall a package **not associated with an installed spec**:

``` bash
$ spack uninstall -f thisdoesnotexist
==> The following packages will be uninstalled : 


==> Do you want to proceed ? [y/n]
```

I wouldn't say the last output is wrong, but surely it can be confusing. @citibeth , @tgamblin would you prefer a different message in case no packages to are found by querying the db ?

I will make a clean dev-branch Spack on CentOS 7 and post the results of my
test.

On Thu, Apr 28, 2016 at 4:26 AM, Massimiliano Culpo <
notifications@github.com> wrote:

> TLDR
> 
> I cannot reproduce the problem, so it's hard for me to look into that with
> a debugger. From the output you posted it seems that your query openblas
> didn't produce any matching installed specs. At first glance this may be
> due to one of these two calls gone wrong :
> 
> specs = spack.cmd.parse_specs(args.packages)
> uninstall_list = concretize_specs(specs, args.all, args.force)...
> 
> The second one involves a query to the db, so... can you re-try after a spack
> reindex to see if this solves the issue?
> Details
> 
> Output I get when trying to uninstall a package _associated with multiple
> installed specs_:
> 
> $ spack uninstall -f  szip
> ==> Error: szip matches multiple packages:
> 
> -- production / clang@3.8.0 -------------------------------------
> uldzrgd szip@2.1
> 
> -- production / gcc@4.8 -----------------------------------------
> 35xe6vt szip@2.1
> 
> -- production / gcc@5.3.0 ---------------------------------------
> a3rdlo5 szip@2.1
> 
> ==> Error: You can either:
>     a) Use a more specific spec, or
>     b) use spack uninstall -a to uninstall ALL matching specs.
> 
> Output I get when trying to uninstall a package _associated with a single
> installed spec_:
> 
> $ spack uninstall -f  szip%clang
> ==> The following packages will be uninstalled :
> 
> -- production / clang@3.8.0 -------------------------------------
> uldzrgd szip@2.1
> 
> ==> Do you want to proceed ? [y/n]
> 
> Output I get when trying to uninstall a package _not associated with an
> installed spec_:
> 
> $ spack uninstall -f thisdoesnotexist
> ==> The following packages will be uninstalled :
> 
> ==> Do you want to proceed ? [y/n]
> 
> I wouldn't say the last output is wrong, but surely it can be confusing.
> @citibeth https://github.com/citibeth , @tgamblin
> https://github.com/tgamblin would you prefer a different message in
> case no packages to are found by querying the db ?
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly or view it on GitHub
> https://github.com/LLNL/spack/issues/858#issuecomment-215350456

@citibeth In any case I think the message to the user should be improved if nothing matches the query. What's there is really tricky, in particular considering that you're asked permission to proceed on doing nothing...

@citibeth Any news on this issue?

@citibeth: can you still reproduce this?

With 6mo hindsight, my guess is this was some database problem that would have been fixed with `spack reindex`.  The only thing I might suggest is... if nothing is found that matches, don't ask the user for permission, and say something like:

```
$ spack uninstall -f thisdoesnotexist
==> No packages were found to uninstall.  Doing nothing.
```

Ok PR incoming...

Sure.

##### TLDR

I cannot reproduce the problem, so it's hard for me to look into that with a debugger. From the output you posted it seems that your query `openblas` didn't produce any matching installed specs. At first glance this may be due to one of these two calls gone wrong  :

``` python
specs = spack.cmd.parse_specs(args.packages)
uninstall_list = concretize_specs(specs, args.all, args.force)
...
```

The second one involves a query to the db, so... can you re-try after a `spack reindex` to see if this solves the issue?

##### Details

Output I get when trying to uninstall a package **associated with multiple installed specs**:

``` bash
$ spack uninstall -f  szip
==> Error: szip matches multiple packages:

-- production / clang@3.8.0 -------------------------------------
uldzrgd szip@2.1

-- production / gcc@4.8 -----------------------------------------
35xe6vt szip@2.1

-- production / gcc@5.3.0 ---------------------------------------
a3rdlo5 szip@2.1

==> Error: You can either:
    a) Use a more specific spec, or
    b) use spack uninstall -a to uninstall ALL matching specs.
```

Output I get when trying to uninstall a package **associated with a single installed spec**:

``` bash
$ spack uninstall -f  szip%clang
==> The following packages will be uninstalled : 

-- production / clang@3.8.0 -------------------------------------
uldzrgd szip@2.1

==> Do you want to proceed ? [y/n]
```

Output I get when trying to uninstall a package **not associated with an installed spec**:

``` bash
$ spack uninstall -f thisdoesnotexist
==> The following packages will be uninstalled : 


==> Do you want to proceed ? [y/n]
```

I wouldn't say the last output is wrong, but surely it can be confusing. @citibeth , @tgamblin would you prefer a different message in case no packages to are found by querying the db ?

I will make a clean dev-branch Spack on CentOS 7 and post the results of my
test.

On Thu, Apr 28, 2016 at 4:26 AM, Massimiliano Culpo <
notifications@github.com> wrote:

> TLDR
> 
> I cannot reproduce the problem, so it's hard for me to look into that with
> a debugger. From the output you posted it seems that your query openblas
> didn't produce any matching installed specs. At first glance this may be
> due to one of these two calls gone wrong :
> 
> specs = spack.cmd.parse_specs(args.packages)
> uninstall_list = concretize_specs(specs, args.all, args.force)...
> 
> The second one involves a query to the db, so... can you re-try after a spack
> reindex to see if this solves the issue?
> Details
> 
> Output I get when trying to uninstall a package _associated with multiple
> installed specs_:
> 
> $ spack uninstall -f  szip
> ==> Error: szip matches multiple packages:
> 
> -- production / clang@3.8.0 -------------------------------------
> uldzrgd szip@2.1
> 
> -- production / gcc@4.8 -----------------------------------------
> 35xe6vt szip@2.1
> 
> -- production / gcc@5.3.0 ---------------------------------------
> a3rdlo5 szip@2.1
> 
> ==> Error: You can either:
>     a) Use a more specific spec, or
>     b) use spack uninstall -a to uninstall ALL matching specs.
> 
> Output I get when trying to uninstall a package _associated with a single
> installed spec_:
> 
> $ spack uninstall -f  szip%clang
> ==> The following packages will be uninstalled :
> 
> -- production / clang@3.8.0 -------------------------------------
> uldzrgd szip@2.1
> 
> ==> Do you want to proceed ? [y/n]
> 
> Output I get when trying to uninstall a package _not associated with an
> installed spec_:
> 
> $ spack uninstall -f thisdoesnotexist
> ==> The following packages will be uninstalled :
> 
> ==> Do you want to proceed ? [y/n]
> 
> I wouldn't say the last output is wrong, but surely it can be confusing.
> @citibeth https://github.com/citibeth , @tgamblin
> https://github.com/tgamblin would you prefer a different message in
> case no packages to are found by querying the db ?
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly or view it on GitHub
> https://github.com/LLNL/spack/issues/858#issuecomment-215350456

@citibeth In any case I think the message to the user should be improved if nothing matches the query. What's there is really tricky, in particular considering that you're asked permission to proceed on doing nothing...

@citibeth Any news on this issue?

@citibeth: can you still reproduce this?

With 6mo hindsight, my guess is this was some database problem that would have been fixed with `spack reindex`.  The only thing I might suggest is... if nothing is found that matches, don't ask the user for permission, and say something like:

```
$ spack uninstall -f thisdoesnotexist
==> No packages were found to uninstall.  Doing nothing.
```

Ok PR incoming...


Resolving patch:
diff --git a/lib/spack/spack/cmd/uninstall.py b/lib/spack/spack/cmd/uninstall.py
--- a/lib/spack/spack/cmd/uninstall.py
+++ b/lib/spack/spack/cmd/uninstall.py
@@ -99,7 +99,7 @@ def concretize_specs(specs, allow_multiple_matches=False, force=False):
             has_errors = True
 
         # No installed package matches the query
-        if len(matching) == 0 and not force:
+        if len(matching) == 0:
             tty.error("%s does not match any installed packages." % spec)
             has_errors = True
 


Test patch: