pdm-project / pdm-venv

A plugin for pdm that enables virtualenv management
https://pdm-project.github.io/pdm-venv
MIT License
24 stars 4 forks source link

[powershell] ```pdm venv activate``` doesn't work #10

Closed jamestansx closed 3 years ago

jamestansx commented 3 years ago

Describe the bug A clear and concise description of what the bug is. pdm venv activate doesn't work in powershell. Calling the command doesn't activate the venv env. To Reproduce Steps to reproduce the behavior:

  1. pdm venv create -n test
  2. pdm use
  3. pdm venv activate test
  4. virtualenv env isn't activated

Expected behavior A clear and concise description of what you expected to happen. Calling pdm venv activate should auto detect the shell used and activate the appropriate script as by manually run activate.ps1 works.

Screenshots If applicable, add screenshots to help explain your problem. image

System (please complete the following information):

Additional context Add any other context about the problem here. pdm-venv is installed via pdm plugin add pdm-venv

frostming commented 3 years ago

It works, pdm venv activate <env_name> only outputs the command and you need to execute yourself. On PowerShell you can do:

PS> . (pdm venv activate)

The .ps1 extension name is optional. Note the first character is a dot.

jamestansx commented 3 years ago

Tested, it works. Thanks.

But actually won't it be better if running pdm venv activate <env_name> auto activate the env, without users create alias?

frostming commented 3 years ago

The activate command changes the current shell process(the instruction tells you to prefix with source), while pdm ... spawns a new process and any modifications based upon that can't impact the current process. Pipenv and Poetry's shell command spawns a new process, but with a lot of bugs and inconsistencies.

PDM just doesn't want to bother with that. It only adds a little effort to the user side but keeps the user experience of the fancy shell.