From 33e948c2b069b11c5c26c375d8e38b5b9d408e5c Mon Sep 17 00:00:00 2001 From: Brian Marroquin Date: Mon, 19 Sep 2022 00:21:23 -0700 Subject: [PATCH] adds fallback behavior for non-ms shells (cherry picked from commit 770a8148c9ceb583053578af0480e815af01614f) --- src/poetry/utils/shell.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/poetry/utils/shell.py b/src/poetry/utils/shell.py index 431879a52b4..2275a6a01bf 100644 --- a/src/poetry/utils/shell.py +++ b/src/poetry/utils/shell.py @@ -78,12 +78,22 @@ def activate(self, env: VirtualEnv) -> int | None: if sys.platform == "win32": if self._name in ("powershell", "pwsh"): args = ["-NoExit", "-File", str(activate_path)] - else: + elif self._name == "cmd": # /K will execute the bat file and # keep the cmd process from terminating args = ["/K", str(activate_path)] - completed_proc = subprocess.run([self.path, *args]) - return completed_proc.returncode + else: + args = None + + if args: + completed_proc = subprocess.run([self.path, *args]) + return completed_proc.returncode + else: + # If no args are set, execute the shell within the venv + # This activates it, but there could be some features missing: + # deactivate command might not work + # shell prompt will not be modified. + return env.execute(self._path) import shlex