From e29b3a5cdfc21a40eb1a1281e0719e1e284506a3 Mon Sep 17 00:00:00 2001 From: "finswimmer77@gmail.com" Date: Sun, 8 Mar 2020 08:16:43 +0100 Subject: [PATCH 1/3] new (utils.shell): try to find shell via os.environ if detect_shell fail --- poetry/utils/shell.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/poetry/utils/shell.py b/poetry/utils/shell.py index e883c80fc6e..0e0de45275a 100644 --- a/poetry/utils/shell.py +++ b/poetry/utils/shell.py @@ -9,6 +9,7 @@ from shellingham import detect_shell from ._compat import WINDOWS +from ._compat import Path from .env import VirtualEnv @@ -41,7 +42,16 @@ def get(cls): # type: () -> Shell try: name, path = detect_shell(os.getpid()) - except (RuntimeError, ShellDetectionFailure): + except ShellDetectionFailure: + if os.name == "posix": + shell = os.environ["SHELL"] + elif os.name == "nt": + shell = os.environ["COMSPEC"] + else: + raise RuntimeError + + name, path = Path(shell).stem, shell + except RuntimeError: raise RuntimeError("Unable to detect the current shell.") cls._shell = cls(name, path) From 8c3a07134539b944ad3e5f75f71185b500784148 Mon Sep 17 00:00:00 2001 From: "finswimmer77@gmail.com" Date: Mon, 9 Mar 2020 06:33:05 +0100 Subject: [PATCH 2/3] fix (utils.shell): pass error message when finding shell via environment variable fails as well --- poetry/utils/shell.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/poetry/utils/shell.py b/poetry/utils/shell.py index 0e0de45275a..d93bf16c7fb 100644 --- a/poetry/utils/shell.py +++ b/poetry/utils/shell.py @@ -48,7 +48,7 @@ def get(cls): # type: () -> Shell elif os.name == "nt": shell = os.environ["COMSPEC"] else: - raise RuntimeError + raise RuntimeError("Unable to detect the current shell.") name, path = Path(shell).stem, shell except RuntimeError: From 0b2af04b7e48741f725e223e99ea91fd7f496701 Mon Sep 17 00:00:00 2001 From: finswimmer Date: Sat, 4 Apr 2020 21:21:02 +0200 Subject: [PATCH 3/3] change (util.shell): check if env variables are available --- poetry/utils/shell.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/poetry/utils/shell.py b/poetry/utils/shell.py index d93bf16c7fb..b18bda0dd20 100644 --- a/poetry/utils/shell.py +++ b/poetry/utils/shell.py @@ -42,17 +42,18 @@ def get(cls): # type: () -> Shell try: name, path = detect_shell(os.getpid()) - except ShellDetectionFailure: + except (RuntimeError, ShellDetectionFailure): + shell = None + if os.name == "posix": - shell = os.environ["SHELL"] + shell = os.environ.get("SHELL") elif os.name == "nt": - shell = os.environ["COMSPEC"] - else: + shell = os.environ.get("COMSPEC") + + if not shell: raise RuntimeError("Unable to detect the current shell.") name, path = Path(shell).stem, shell - except RuntimeError: - raise RuntimeError("Unable to detect the current shell.") cls._shell = cls(name, path)