From 8e2e819f2e506128ee98cf6ab1320f87d476f18c Mon Sep 17 00:00:00 2001 From: Miikka Koskinen Date: Sun, 14 May 2023 08:29:42 +0300 Subject: [PATCH] fix: fix `poetry shell` for nushell This commit contains two fixes: 1. the virtualenv activation command was not actually being sent 2. the correct command is `overlay use`, not `source` Reference for the correct command: https://github.com/pypa/virtualenv/blob/64bec9be8d412d7e7439987f565f7070e66cdf5a/src/virtualenv/activation/nushell/activate.nu#L2 Tested with nushell 0.78.0. --- src/poetry/utils/shell.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/poetry/utils/shell.py b/src/poetry/utils/shell.py index 38457206b8b..d60998f0b0e 100644 --- a/src/poetry/utils/shell.py +++ b/src/poetry/utils/shell.py @@ -104,13 +104,14 @@ def activate(self, env: VirtualEnv) -> int | None: if self._name in ["zsh", "nu"]: c.setecho(False) - 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))}'") + + 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: cmd = f"{self._get_source_command()} {shlex.quote(str(activate_path))}" - if self._name == "fish": - # Under fish "\r" should be sent explicitly + if self._name in ["fish", "nu"]: + # Under fish and nu "\r" should be sent explicitly cmd += "\r" c.sendline(cmd) @@ -143,8 +144,10 @@ def _get_activate_script(self) -> str: return "activate" + suffix def _get_source_command(self) -> str: - if self._name in ("fish", "csh", "tcsh", "nu"): + if self._name in ("fish", "csh", "tcsh"): return "source" + elif self._name == "nu": + return "overlay use" return "." def __repr__(self) -> str: