Skip to content

Commit

Permalink
fix: fix poetry shell for nushell
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
miikka committed May 14, 2023
1 parent e5bbc60 commit ed60aec
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/poetry/utils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit ed60aec

Please sign in to comment.