pyenv-win / pyenv-win-venv

A CLI to manage virtual envs with pyenv-win
Apache License 2.0
85 stars 8 forks source link

Activating venv in PowerShell opens venv in CLI #26

Open Stonemuzzle opened 6 months ago

Stonemuzzle commented 6 months ago

When running pyenv-venv activate in a PowerShell session in Windows Terminal, the activated venv uses Windows CLI instead of PowerShell.

The pyenv-win-venv.ps1 script uses $MyInvocation.MyCommand.CommandType -eq "ExternalScript" to determine whether to use the activate.bat or the Activate.ps1 file to activate the venv. This always evaluates to "ExternalScript" since the pyenv-venv command is triggering the script, from which the command is then run.

I resolved locally by changing the check in the pyenv-win-venv.ps1 file to:

if ($PSVersionTable) {
    $invokedShell = "ps1"
} else {
    $invokedShell = "bat"

Environment:

nayjsilva commented 4 months ago

Encountered the same issue, the fix above did the trick.

awonglk commented 1 month ago

Same issue. Is there any plans to fix this permanently?