From a8745be6ba729d7d8227ac1cb2d80481f51cb3fc Mon Sep 17 00:00:00 2001 From: ralbertazzi Date: Fri, 19 May 2023 12:58:14 +0200 Subject: [PATCH] fix: fix exception on invalid url dependency for current env --- src/poetry/installation/executor.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/poetry/installation/executor.py b/src/poetry/installation/executor.py index f98ce2d1c73..a46ee04a32c 100644 --- a/src/poetry/installation/executor.py +++ b/src/poetry/installation/executor.py @@ -780,9 +780,15 @@ def _download_link(self, operation: Install | Update, link: Link) -> Path: strict=False, env=self._env, ) - # 'archive' can at this point never be None. Since we previously downloaded - # an archive, we now should have something cached that we can use here - assert archive is not None + if archive is None: + # Since we previously downloaded an archive, we now should have + # something cached that we can use here. The only case in which + # archive is None is if the original archive is not valid for the + # current environment. + raise RuntimeError( + f"Package {link.url} cannot be installed in the current environment" + f" {self._env.marker_env}" + ) if archive.suffix != ".whl": message = (