From 257bbbc5abfc235d01e93962fb5e78675c658181 Mon Sep 17 00:00:00 2001 From: Marius van Niekerk Date: Wed, 29 Mar 2023 11:39:01 -0400 Subject: [PATCH] Under some rare (and as of yet undetermined conditions virtual pacakges can make their way into the compute_final_precs function. This change should allow those to be safely ignored --- mamba/mamba/utils.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/mamba/mamba/utils.py b/mamba/mamba/utils.py index 8284b1471d..1c010f0f02 100644 --- a/mamba/mamba/utils.py +++ b/mamba/mamba/utils.py @@ -365,11 +365,18 @@ def compute_final_precs( entry["channel"].platform_url(entry["platform"], with_credentials=False) ] = entry + i_rec: PackageRecord for _, pkg in to_unlink: for i_rec in installed_pkg_recs: if i_rec.fn == pkg: - final_precs.remove(i_rec) - to_unlink_records.append(i_rec) + try: + final_precs.remove(i_rec) + to_unlink_records.append(i_rec) + except KeyError: + # virtual packages cannot be unlinked as they do not exist + if i_rec.package_type == "virtual_system": + continue + raise break else: print("No package record found!") @@ -391,6 +398,10 @@ def compute_final_precs( if ipkg.name == rec.name: rec.noarch = ipkg.noarch + # virtual packages cannot be linked as they do not exist + if rec.package_type == "virtual_system": + continue + final_precs.add(rec) to_link_records.append(rec)