From 9805314ea6e888098cb02d640db9376d6bc0caf5 Mon Sep 17 00:00:00 2001 From: Alecto Irene Perez Date: Mon, 6 Jun 2022 11:13:15 -0600 Subject: [PATCH 1/3] Fix shell activation for zsh --- src/poetry/utils/shell.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/poetry/utils/shell.py b/src/poetry/utils/shell.py index 1a5de3c9cf5..666d317deff 100644 --- a/src/poetry/utils/shell.py +++ b/src/poetry/utils/shell.py @@ -95,8 +95,10 @@ def activate(self, env: VirtualEnv) -> int | None: if self._name == "zsh": c.setecho(False) - - c.sendline(f"{self._get_source_command()} {shlex.quote(str(activate_path))}") + # Under ZSH the source command should be invoked in zsh's bash emulator + c.sendline(f"emulate bash -c '. {shlex.quote(str(activate_path))}'") + else: + c.sendline(f"{self._get_source_command()} {shlex.quote(str(activate_path))}") def resize(sig: Any, data: Any) -> None: terminal = Terminal() From 051eefa97fbe01ff9b2c3dd8cd39749c4d254d1a Mon Sep 17 00:00:00 2001 From: Alecto Irene Perez Date: Tue, 7 Jun 2022 11:18:05 -0600 Subject: [PATCH 2/3] Fix formatting with black --- src/poetry/utils/shell.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/poetry/utils/shell.py b/src/poetry/utils/shell.py index 666d317deff..9ba3ee68c95 100644 --- a/src/poetry/utils/shell.py +++ b/src/poetry/utils/shell.py @@ -98,7 +98,9 @@ def activate(self, env: VirtualEnv) -> int | None: # Under ZSH the source command should be invoked in zsh's bash emulator c.sendline(f"emulate bash -c '. {shlex.quote(str(activate_path))}'") else: - c.sendline(f"{self._get_source_command()} {shlex.quote(str(activate_path))}") + c.sendline( + f"{self._get_source_command()} {shlex.quote(str(activate_path))}" + ) def resize(sig: Any, data: Any) -> None: terminal = Terminal() From 42625bb32036368f06e8e0b52416963578d958a1 Mon Sep 17 00:00:00 2001 From: Bartosz Sokorski Date: Tue, 6 Sep 2022 23:37:02 +0200 Subject: [PATCH 3/3] Update to include changes made for nushell --- src/poetry/utils/shell.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/poetry/utils/shell.py b/src/poetry/utils/shell.py index 7505ef6221f..45d002fec85 100644 --- a/src/poetry/utils/shell.py +++ b/src/poetry/utils/shell.py @@ -95,8 +95,9 @@ def activate(self, env: VirtualEnv) -> int | None: if self._name in ["zsh", "nu"]: c.setecho(False) - # Under ZSH the source command should be invoked in zsh's bash emulator - c.sendline(f"emulate bash -c '. {shlex.quote(str(activate_path))}'") + if self._name == "zsh": + # Under ZSH the source command should be invoked in zsh's bash emulator + c.sendline(f"emulate bash -c '. {shlex.quote(str(activate_path))}'") else: c.sendline( f"{self._get_source_command()} {shlex.quote(str(activate_path))}"