Skip to content

Commit

Permalink
fix: specify venv activator as init script when starting PowerShell
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis-yeung committed Jul 7, 2024
1 parent a7d234c commit 96dc7d2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/poetry/utils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ def activate(self, env: VirtualEnv) -> int | None:
args = ["-e", cmd]
elif self._name == "fish":
args = ["-i", "--init-command", cmd]
elif self._name in ("powershell", "pwsh"):
args = ["-NoExit", "-File", str(activate_path)]
else:
args = ["-i"]

Expand All @@ -126,9 +128,10 @@ def activate(self, env: VirtualEnv) -> int | None:
c.sendline(f"emulate bash -c {shlex.quote(f'. {quoted_activate_path}')}")
elif self._name == "xonsh":
c.sendline(f"vox activate {shlex.quote(str(env.path))}")
elif self._name in ["nu", "fish"]:
# If this is nu or fish, we don't want to send the activation command to the
# command line since we already ran it via the shell's invocation.
elif self._name in ["nu", "fish", "powershell", "pwsh"]:
# If this is nu, fish or PowerShell, we don't want to send the activation
# command to the command line since we already ran it via the shell's
# invocation.
pass
else:
c.sendline(cmd)
Expand Down

0 comments on commit 96dc7d2

Please sign in to comment.