Skip to content

Commit 6ae3c28

Browse files
authored
Fix _remove to catch EnvCommandError instead of CalledProcessError (#10740)
run_pip() wraps CalledProcessError inside EnvCommandError, so the except CalledProcessError handler in _remove() was dead code. If pip exited non-zero with 'not installed' in its output, the EnvCommandError would propagate uncaught to _execute_operation, which treats it as a fatal error and aborts the entire installation. This matters when removing a package that was already uninstalled externally — e.g. via pip directly — while Poetry is performing an update.
1 parent ad9ab00 commit 6ae3c28

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

src/poetry/installation/executor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from concurrent.futures import ThreadPoolExecutor
1111
from concurrent.futures import wait
1212
from pathlib import Path
13-
from subprocess import CalledProcessError
1413
from typing import TYPE_CHECKING
1514
from typing import Any
1615

@@ -624,7 +623,7 @@ def _remove(self, package: Package) -> int:
624623

625624
try:
626625
return self.run_pip("uninstall", package.name, "-y")
627-
except CalledProcessError as e:
626+
except EnvCommandError as e:
628627
if "not installed" in str(e):
629628
return 0
630629

0 commit comments

Comments
 (0)