Repository: spack/spack

Issue:
intel-mpi from system: Error: super() argument 1 must be type, not IntelMpi
### Steps to reproduce the issue

```console
$ git clone https://github.com/spack/spack.git
$ cat > spack/etc/spack/defaults/compilers.yaml <<EOL
compilers:
- compiler:
    paths:
      cc:  /opt/gcc-9.2.0/bin/gcc
      cxx: /opt/gcc-9.2.0/bin/g++
      f77: /opt/gcc-9.2.0/bin/gfortran
      fc:  /opt/gcc-9.2.0/bin/gfortran
    operating_system: centos7
    target: x86_64
    modules: []
    environment: {}
    extra_rpaths: []
    flags: {}
    spec: gcc@9.2.0
EOL
$ cat >> spack/etc/spack/defaults/packages.yaml <<EOL

  mpi:
    buildable: false
    modules:
      intel-mpi@2019.7.217 %gcc@9.2.0: mpi/impi_2019.7.217
      openmpi@4.0.3        %gcc@9.2.0: mpi/openmpi-4.0.3
EOL
```

### Error Message
```console
$ source spack/share/spack/setup-env.sh
$ spack install osu-micro-benchmarks arch=linux-centos7-x86_64 ^intel-mpi
==> intel-mpi@2019.7.217 : has external module in mpi/impi_2019.7.217
==> intel-mpi@2019.7.217 : is actually installed in None
==> intel-mpi@2019.7.217 : generating module file
==> Error: super() argument 1 must be type, not IntelMpi
```

Using `openmpi` works as expected:
```
$ spack install osu-micro-benchmarks arch=linux-centos7-x86_64 ^openmpi
```

Any ideas?

Thanks



Discussion:
Using `paths` instead of `modules`:
```console
cat >> spack/etc/spack/defaults/packages.yaml <<EOL

  mpi:
    modules:
      openmpi@4.0.3        %gcc@9.2.0: mpi/openmpi-4.0.3
    paths:
       intel-mpi@2019.7.217: /opt/intel/compilers_and_libraries_2020.1.217/linux/mpi
    buildable: false
EOL
```
returns the same error:
```
$ spack install osu-micro-benchmarks arch=linux-centos7-x86_64 ^intel-mpi
==> intel-mpi@2019.7.217 : externally installed in /opt/intel/compilers_and_libraries_2020.1.217/linux/mpi
==> intel-mpi@2019.7.217 : generating module file
==> Error: super() argument 1 must be type, not IntelMpi
```


Can you post the result of:
```console
$ spack -d install osu-micro-benchmarks arch=linux-centos7-x86_64 ^intel-mpi
```
The `-d` option after `spack` enables debug output and should print the entire stacktrace for the error.
Sure.
To `spack/etc/spack/defaults/packages.yaml` I have added:
```console
  mpi:
    modules:
      intel-mpi @2019.7.217 %gcc@9.2.0: mpi/impi_2019.7.217
      openmpi   @4.0.3      %gcc@9.2.0: mpi/openmpi-4.0.3
    buildable: false
```
and I get:
```console
$ spack -d install osu-micro-benchmarks arch=linux-centos7-x86_64 ^intel-mpi
==> [2020-06-23-08:27:58.830611, 15665] Imported install from built-in commands
==> [2020-06-23-08:27:58.833477, 15665] Reading config file /shared/home/vgervasi/osu/spack/etc/spack/defaults/config.yaml
==> [2020-06-23-08:27:58.856974, 15665] Imported install from built-in commands
==> [2020-06-23-08:27:58.861047, 15665] Reading config file /shared/home/vgervasi/osu/spack/etc/spack/defaults/repos.yaml
==> [2020-06-23-08:28:04.621466, 15665] Reading config file /shared/home/vgervasi/osu/spack/etc/spack/defaults/packages.yaml
==> [2020-06-23-08:28:04.656709, 15665] Reading config file /shared/home/vgervasi/osu/spack/etc/spack/defaults/compilers.yaml
==> [2020-06-23-08:28:04.697201, 15665] Module name: mpi/impi_2019.7.217
==> [2020-06-23-08:28:04.697394, 15665] Package directory variable prefix: MPI
==> [2020-06-23-08:28:04.703937, 15665] DATABASE LOCK TIMEOUT: 3s
==> [2020-06-23-08:28:04.704007, 15665] PACKAGE LOCK TIMEOUT: No timeout
==> [2020-06-23-08:28:04.704466, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Acquiring]
==> [2020-06-23-08:28:04.707332, 15665] read locking [0:0]: timeout 3 sec
==> [2020-06-23-08:28:04.709954, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Acquired at 08:28:04.709910]
==> [2020-06-23-08:28:04.719514, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Releasing]
==> [2020-06-23-08:28:04.721325, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Released at 08:28:04.721288]
==> [2020-06-23-08:28:04.722958, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Acquiring]
==> [2020-06-23-08:28:04.725704, 15665] read locking [0:0]: timeout 3 sec
==> [2020-06-23-08:28:04.726500, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Acquired at 08:28:04.726473]
==> [2020-06-23-08:28:04.727662, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Releasing]
==> [2020-06-23-08:28:04.728506, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Released at 08:28:04.728482]
==> [2020-06-23-08:28:04.728561, 15665] Initializing the build queue for osu-micro-benchmarks
==> [2020-06-23-08:28:04.729639, 15665] READ LOCK (intel-mpi): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/prefix_failures[5167930961078574149:1] [Acquiring]
==> [2020-06-23-08:28:04.733280, 15665] read locking [5167930961078574149:1]: timeout None sec
==> [2020-06-23-08:28:04.734098, 15665] READ LOCK (intel-mpi): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/prefix_failures[5167930961078574149:1] [Acquired at 08:28:04.734071]
==> [2020-06-23-08:28:04.734155, 15665] READ LOCK (intel-mpi): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/prefix_failures[5167930961078574149:1] [Releasing]
==> [2020-06-23-08:28:04.734940, 15665] READ LOCK (intel-mpi): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/prefix_failures[5167930961078574149:1] [Released at 08:28:04.734916]
==> [2020-06-23-08:28:04.735009, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Acquiring]
==> [2020-06-23-08:28:04.737645, 15665] read locking [0:0]: timeout 3 sec
==> [2020-06-23-08:28:04.738405, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Acquired at 08:28:04.738379]
==> [2020-06-23-08:28:04.739372, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Releasing]
==> [2020-06-23-08:28:04.740226, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Released at 08:28:04.740197]
==> [2020-06-23-08:28:04.747687, 15665] READ LOCK (osu-micro-benchmarks): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/prefix_failures[2979389045681192481:1] [Acquiring]
==> [2020-06-23-08:28:04.752229, 15665] read locking [2979389045681192481:1]: timeout None sec
==> [2020-06-23-08:28:04.753057, 15665] READ LOCK (osu-micro-benchmarks): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/prefix_failures[2979389045681192481:1] [Acquired at 08:28:04.753030]
==> [2020-06-23-08:28:04.753114, 15665] READ LOCK (osu-micro-benchmarks): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/prefix_failures[2979389045681192481:1] [Releasing]
==> [2020-06-23-08:28:04.754667, 15665] READ LOCK (osu-micro-benchmarks): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/prefix_failures[2979389045681192481:1] [Released at 08:28:04.754631]
==> [2020-06-23-08:28:04.754763, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Acquiring]
==> [2020-06-23-08:28:04.757519, 15665] read locking [0:0]: timeout 3 sec
==> [2020-06-23-08:28:04.758323, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Acquired at 08:28:04.758290]
==> [2020-06-23-08:28:04.759191, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Releasing]
==> [2020-06-23-08:28:04.759987, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Released at 08:28:04.759964]
==> [2020-06-23-08:28:04.760058, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Acquiring]
==> [2020-06-23-08:28:04.763763, 15665] read locking [0:0]: timeout 3 sec
==> [2020-06-23-08:28:04.764595, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Acquired at 08:28:04.764562]
==> [2020-06-23-08:28:04.765464, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Releasing]
==> [2020-06-23-08:28:04.766259, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Released at 08:28:04.766235]
==> [2020-06-23-08:28:04.784163, 15665] intel-mpi@2019.7.217 : has external module in mpi/impi_2019.7.217
==> [2020-06-23-08:28:04.784230, 15665] intel-mpi@2019.7.217 : is actually installed in None
==> [2020-06-23-08:28:04.784308, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Acquiring]
==> [2020-06-23-08:28:04.786983, 15665] read locking [0:0]: timeout 3 sec
==> [2020-06-23-08:28:04.787752, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Acquired at 08:28:04.787726]
==> [2020-06-23-08:28:04.788700, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Releasing]
==> [2020-06-23-08:28:04.789535, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Released at 08:28:04.789507]
==> [2020-06-23-08:28:04.789612, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Acquiring]
==> [2020-06-23-08:28:04.792852, 15665] read locking [0:0]: timeout 3 sec
==> [2020-06-23-08:28:04.793709, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Acquired at 08:28:04.793673]
==> [2020-06-23-08:28:04.794623, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Releasing]
==> [2020-06-23-08:28:04.795412, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Released at 08:28:04.795388]
==> [2020-06-23-08:28:04.795991, 15665] intel-mpi@2019.7.217 : generating module file
==> [2020-06-23-08:28:04.816621, 15665] Reading config file /shared/home/vgervasi/osu/spack/etc/spack/defaults/modules.yaml
==> [2020-06-23-08:28:04.830415, 15665] Reading config file /shared/home/vgervasi/osu/spack/etc/spack/defaults/linux/modules.yaml
==> [2020-06-23-08:28:04.835024, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Acquiring]
==> [2020-06-23-08:28:04.837736, 15665] read locking [0:0]: timeout 3 sec
==> [2020-06-23-08:28:04.838547, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Acquired at 08:28:04.838516]
==> [2020-06-23-08:28:04.839374, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Releasing]
==> [2020-06-23-08:28:04.840167, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Released at 08:28:04.840140]
==> [2020-06-23-08:28:04.840234, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Acquiring]
==> [2020-06-23-08:28:04.843775, 15665] read locking [0:0]: timeout 3 sec
==> [2020-06-23-08:28:04.844590, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Acquired at 08:28:04.844564]
==> [2020-06-23-08:28:04.845354, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Releasing]
==> [2020-06-23-08:28:04.846145, 15665] READ LOCK (database): /shared/home/vgervasi/osu/spack/opt/spack/.spack-db/lock[0:0] [Released at 08:28:04.846122]
==> [2020-06-23-08:28:04.848966, 15665]         WRITE: intel-mpi@2019.7.217%gcc@9.2.0 arch=linux-centos7-x86_64/r5yfxka [/shared/home/vgervasi/osu/spack/share/spack/modules/linux-centos7-x86_64/intel-mpi-2019.7.217-gcc-9.2.0-r5yfxka]
Traceback (most recent call last):
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/installer.py", line 287, in _process_external_package
    rec = spack.store.db.get_record(spec)
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/database.py", line 102, in converter
    return function(self, spec_like, *args, **kwargs)
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/database.py", line 1091, in get_record
    key = self._get_matching_spec_key(spec, **kwargs)
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/database.py", line 1086, in _get_matching_spec_key
    raise KeyError("No such spec in database! %s" % spec)
KeyError: 'No such spec in database! intel-mpi@2019.7.217%gcc@9.2.0 arch=linux-centos7-x86_64'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/shared/home/vgervasi/osu/spack/bin/spack", line 64, in <module>
    sys.exit(spack.main.main())
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/main.py", line 761, in main
    return _invoke_command(command, parser, args, unknown)
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/main.py", line 489, in _invoke_command
    return_val = command(parser, args)
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/cmd/install.py", line 382, in install
    install_spec(args, kwargs, abstract, concrete)
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/cmd/install.py", line 239, in install_spec
    spec.package.do_install(**kwargs)
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/package.py", line 1470, in do_install
    builder.install(**kwargs)
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/installer.py", line 1441, in install
    not_local = _handle_external_and_upstream(pkg, False)
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/installer.py", line 98, in _handle_external_and_upstream
    _process_external_package(pkg, explicit)
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/installer.py", line 298, in _process_external_package
    spack.hooks.post_install(spec)
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/hooks/__init__.py", line 59, in __call__
    hook(*args, **kwargs)
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/hooks/module_file_generation.py", line 30, in post_install
    _for_each_enabled(spec, 'write')
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/hooks/module_file_generation.py", line 22, in _for_each_enabled
    getattr(generator, method_name)()
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/modules/common.py", line 816, in write
    context = self.context.to_dict()
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/tengine.py", line 63, in to_dict
    d = [(name, getattr(self, name)) for name in self.context_properties]
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/tengine.py", line 63, in <listcomp>
    d = [(name, getattr(self, name)) for name in self.context_properties]
  File "/shared/home/vgervasi/osu/spack/lib/spack/spack/modules/common.py", line 670, in environment_modifications
    self.spec.package.setup_run_environment(env)
  File "/shared/home/vgervasi/osu/spack/var/spack/repos/builtin/packages/intel-mpi/package.py", line 69, in setup_run_environment

TypeError: super() argument 1 must be type, not IntelMpi
```

Seems that is not able to find `intel-mpi@2019.7.217%gcc@9.2.0 arch=linux-centos7-x86_64`, maybe I need to specify the `arch` option, strangely the same setup works with openmpi.
Even with:
```
  mpi:
    modules:
      intel-mpi @2019.7.217 %gcc@9.2.0 arch=linux-centos7-x86_64: mpi/impi_2019.7.217
      openmpi   @4.0.3      %gcc@9.2.0: mpi/openmpi-4.0.3
    buildable: false
```
same error.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/intel-mpi/package.py b/var/spack/repos/builtin/packages/intel-mpi/package.py
--- a/var/spack/repos/builtin/packages/intel-mpi/package.py
+++ b/var/spack/repos/builtin/packages/intel-mpi/package.py
@@ -65,7 +65,7 @@ def setup_dependent_build_environment(self, *args):
         })
 
     def setup_run_environment(self, env):
-        super(self, IntelMpi).setup_run_environment(env)
+        super(IntelMPI, self).setup_run_environment(env)
 
         for name, value in self.mpi_compiler.wrappers.items():
             env.set(name, value)
diff --git a/var/spack/repos/builtin/packages/intel-parallel-studio/package.py b/var/spack/repos/builtin/packages/intel-parallel-studio/package.py
--- a/var/spack/repos/builtin/packages/intel-parallel-studio/package.py
+++ b/var/spack/repos/builtin/packages/intel-parallel-studio/package.py
@@ -227,7 +227,7 @@ def setup_dependent_build_environment(self, *args):
         })
 
     def setup_run_environment(self, env):
-        super(self, IntelParallelStudio).setup_run_environment(env)
+        super(IntelParallelStudio, self).setup_run_environment(env)
 
         for name, value in self.mpi_compiler_wrappers.items():
             env.set(name, value)


Test patch: