From 67e74da3ba6d548c1fdaf0787cfeab47b9be8a22 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Wed, 17 May 2023 06:24:38 +0200 Subject: Fix `spack find` not able to display version ranges in compilers (#37715) --- lib/spack/spack/cmd/__init__.py | 2 +- lib/spack/spack/test/cmd/find.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/spack/spack/cmd/__init__.py b/lib/spack/spack/cmd/__init__.py index f07173d9fc..df482edfd4 100644 --- a/lib/spack/spack/cmd/__init__.py +++ b/lib/spack/spack/cmd/__init__.py @@ -347,7 +347,7 @@ def iter_groups(specs, indent, all_headers): spack.spec.architecture_color, architecture if architecture else "no arch", spack.spec.compiler_color, - f"{compiler.name}@{compiler.version}" if compiler else "no compiler", + f"{compiler}" if compiler else "no compiler", ) # Sometimes we want to display specs that are not yet concretized. diff --git a/lib/spack/spack/test/cmd/find.py b/lib/spack/spack/test/cmd/find.py index 5c520a97e1..249f93257f 100644 --- a/lib/spack/spack/test/cmd/find.py +++ b/lib/spack/spack/test/cmd/find.py @@ -357,3 +357,18 @@ def test_find_loaded(database, working_env): output = find("--loaded") expected = find() assert output == expected + + +@pytest.mark.regression("37712") +def test_environment_with_version_range_in_compiler_doesnt_fail(tmp_path): + """Tests that having an active environment with a root spec containing a compiler constrained + by a version range (i.e. @X.Y rather the single version than @=X.Y) doesn't result in an error + when invoking "spack find". + """ + test_environment = ev.create_in_dir(tmp_path) + test_environment.add("zlib %gcc@12.1.0") + test_environment.write() + + with test_environment: + output = find() + assert "zlib%gcc@12.1.0" in output -- cgit v1.2.3-60-g2f50