Repository: spack/spack

Issue:
spack find -d does not group
Hi,
I have notice a strange behaviour in the `spack find` command.
If I run:
```
$ spack find
==> 58 installed packages
-- linux-centos7-broadwell / gcc@9.2.0 --------------------------
charmpp@6.10.2  cuda@11.2.0  fftw@3.3.9  libiconv@1.16  libxml2@2.9.10  namd@2.14  xz@5.2.2  zlib@1.2.11

-- linux-centos7-skylake_avx512 / gcc@9.2.0 ---------------------
charmpp@6.10.2  fftw@3.3.9  gromacs@2020.5  hwloc@2.4.0  intel-mkl@2019.5.281  intel-mpi@2019.8.254  libiconv@1.16  libpciaccess@0.16  libxml2@2.9.10  namd@2.14  util-macros@1.19.1  xz@5.2.2  zlib@1.2.11

-- linux-centos7-x86_64 / gcc@9.2.0 -----------------------------
fio@3.25  flex@2.5.37  hpcg@3.1  hpl@2.3  hpl@2.3  intel-mkl@2019.5.281  intel-mpi@2019.8.254  ior@3.3.0  openfoam-org@8  openmpi@4.0.4  osu-micro-benchmarks@5.6.3  osu-micro-benchmarks@5.6.3  scotch@6.0.10  zlib@1.2.11

-- linux-centos7-zen / gcc@9.2.0 --------------------------------
charmpp@6.10.2  fftw@3.3.9  gromacs@2020.5  hwloc@2.4.0  intel-mkl@2019.5.281  intel-mpi@2019.8.254  libiconv@1.16  libpciaccess@0.16  libxml2@2.9.10  namd@2.14  util-macros@1.19.1  xz@5.2.2  zlib@1.2.11

-- linux-centos7-zen2 / gcc@9.2.0 -------------------------------
gromacs@2020.5  hwloc@2.4.0  intel-mkl@2019.5.281  intel-mpi@2019.8.254  libiconv@1.16  libpciaccess@0.16  libxml2@2.9.10  util-macros@1.19.1  xz@5.2.2  zlib@1.2.11
```
As you can see the packages are grouped by the architecture/compiler making the output human readable.

Not if I add the "-d" flag:
```
$ spack find -d
==> 58 installed packages
-- linux-centos7-broadwell / gcc@9.2.0 --------------------------

-- linux-centos7-skylake_avx512 / gcc@9.2.0 ---------------------

-- linux-centos7-x86_64 / gcc@9.2.0 -----------------------------

-- linux-centos7-zen / gcc@9.2.0 --------------------------------

-- linux-centos7-zen2 / gcc@9.2.0 -------------------------------
charmpp@6.10.2

cuda@11.2.0
    libxml2@2.9.10
        libiconv@1.16
        xz@5.2.2
        zlib@1.2.11

fftw@3.3.9

libiconv@1.16

libxml2@2.9.10
    libiconv@1.16
    xz@5.2.2
    zlib@1.2.11

namd@2.14
    charmpp@6.10.2
    cuda@11.2.0
        libxml2@2.9.10
            libiconv@1.16
            xz@5.2.2
            zlib@1.2.11
    fftw@3.3.9

xz@5.2.2

zlib@1.2.11

charmpp@6.10.2
    intel-mpi@2019.8.254

fftw@3.3.9
    intel-mpi@2019.8.254

gromacs@2020.5
    hwloc@2.4.0
        libpciaccess@0.16
        libxml2@2.9.10
            libiconv@1.16
            xz@5.2.2
            zlib@1.2.11
    intel-mkl@2019.5.281
    intel-mpi@2019.8.254

hwloc@2.4.0
    libpciaccess@0.16
    libxml2@2.9.10
        libiconv@1.16
        xz@5.2.2
        zlib@1.2.11

intel-mkl@2019.5.281

intel-mpi@2019.8.254

libiconv@1.16

libpciaccess@0.16

libxml2@2.9.10
    libiconv@1.16
    xz@5.2.2
    zlib@1.2.11

namd@2.14
    charmpp@6.10.2
        intel-mpi@2019.8.254
    fftw@3.3.9

util-macros@1.19.1

xz@5.2.2

zlib@1.2.11

fio@3.25

flex@2.5.37

hpcg@3.1
    openmpi@4.0.4

hpl@2.3
    intel-mkl@2019.5.281
    intel-mpi@2019.8.254

hpl@2.3
    intel-mkl@2019.5.281
    openmpi@4.0.4

intel-mkl@2019.5.281

intel-mpi@2019.8.254

ior@3.3.0
    openmpi@4.0.4

openfoam-org@8
    flex@2.5.37
    openmpi@4.0.4
    scotch@6.0.10
        zlib@1.2.11

openmpi@4.0.4

osu-micro-benchmarks@5.6.3
    intel-mpi@2019.8.254

osu-micro-benchmarks@5.6.3
    openmpi@4.0.4

scotch@6.0.10
    openmpi@4.0.4
    zlib@1.2.11

zlib@1.2.11

charmpp@6.10.2
    intel-mpi@2019.8.254

fftw@3.3.9
    intel-mpi@2019.8.254

gromacs@2020.5
    hwloc@2.4.0
        libpciaccess@0.16
        libxml2@2.9.10
            libiconv@1.16
            xz@5.2.2
            zlib@1.2.11
    intel-mkl@2019.5.281
    intel-mpi@2019.8.254

hwloc@2.4.0
    libpciaccess@0.16
    libxml2@2.9.10
        libiconv@1.16
        xz@5.2.2
        zlib@1.2.11

intel-mkl@2019.5.281

intel-mpi@2019.8.254

libiconv@1.16

libpciaccess@0.16
...
```
The installed packages are not grouped anymore by architecture/compiler and makes very difficult to understand which package is build for which architecture/compiler.
Same output with `spack find -d --groups`.

Is this the desired behaviour?

Thanks



Discussion:

Resolving patch:
diff --git a/lib/spack/spack/cmd/__init__.py b/lib/spack/spack/cmd/__init__.py
--- a/lib/spack/spack/cmd/__init__.py
+++ b/lib/spack/spack/cmd/__init__.py
@@ -435,7 +435,7 @@ def format_list(specs):
     out = ''
     if groups:
         for specs in iter_groups(specs, indent, all_headers):
-            out += format_list(specs)
+            output.write(format_list(specs))
     else:
         out = format_list(sorted(specs))
 


Test patch: