Skip to content

Error in Environment.matching_specs() method #23333

@scottwittenburg

Description

@scottwittenburg

Today I hit an error in this line. The problem there is that root_matches is a dictionary mapping concrete specs to abstract specs, but it is indexed with an integer.

I hit this while attempting to use matching_spec() in #22657, but you can also make it happen using the spack location command (or probably any command that uses spack.cmd.matching_spec_from_env(spec)).

Steps to reproduce the issue

It seems you need to have an environment where a particular package appears both as a root and a dependency (so concretized separately), but that might not be the complete necessary/sufficient set of conditions. To create an example problem environment:

$ spack env create foo
$ spack env activate foo
$ spack add readline
$ spack add ncurses ~termlib
$ spack concretize

Now the foo environment contains two ncurses specs.

Error Message

To cause the error:

$ spack -d location -s ncurses
==> [2021-04-28-15:41:16.385703] Imported location from built-in commands
==> [2021-04-28-15:41:16.387569] Imported location from built-in commands
==> [2021-04-28-15:41:16.388594] Reading config file /projects/spack/etc/spack/defaults/repos.yaml
==> [2021-04-28-15:41:16.392801] Reading config file /projects/spack/var/spack/environments/blah/spack.yaml
Traceback (most recent call last):
  File "/projects/spack/bin/spack", line 76, in <module>
    sys.exit(spack.main.main())
  File "/projects/spack/lib/spack/spack/main.py", line 772, in main
    return _invoke_command(command, parser, args, unknown)
  File "/projects/spack/lib/spack/spack/main.py", line 496, in _invoke_command
    return_val = command(parser, args)
  File "/projects/spack/lib/spack/spack/cmd/location.py", line 112, in location
    spec = spack.cmd.matching_spec_from_env(spec)
  File "/projects/spack/lib/spack/spack/cmd/__init__.py", line 192, in matching_spec_from_env
    return env.matching_spec(spec) or spec.concretized()
  File "/projects/spack/lib/spack/spack/environment.py", line 1588, in matching_spec
    return root_matches[0][1]
KeyError: 0

Information on your system

$ spack debug report
* **Spack:** 0.16.1-2415-ceacc6706f
* **Python:** 3.6.9
* **Platform:** linux-ubuntu18.04-haswell
* **Concretizer:** original

Additional information

  • I have run spack debug report and reported the version of Spack/Python/Platform
  • I have searched the issues of this repo and believe this is not a duplicate
  • I have run the failing commands in debug mode and reported the output

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriageThe issue needs to be prioritized

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions