[New-bugs-announce] [issue39505] redundant ‘/’ in $env:VIRTUAL_ENV when use venv in powershell

Fuzheng Duan report at bugs.python.org
Fri Jan 31 03:24:20 EST 2020

New submission from Fuzheng Duan <duanfuzheng at gmail.com>:

When windows users use "python -m venv ENV_DIR", a python virtual environment will be created in ENV_DIR. 
Powershell users use ENV_DIR\Scripts\Activate.ps1 to activate virtual environment.
In powershell, a environment variable, "$env:VIRTUAL_ENV", is set and used by many tools to determine that there is an activated venv. In bash, it is "$VIRTUAL_ENV"
In python3.8 and python3.9, $env:VIRTUAL_ENV has a redundant '/', for example:
PS C:\Users\Test> python -m venv test_venv
PS C:\Users\Test> .\test_venv\Scripts\Activate.ps1
PS C:\Users\Test> $env:VIRTUAL_ENV

using python3.7, or using virtualenv with python3.8 or 3.9, or in linux, there will be no such a '/' in the end.

This '/' matters because some tools many tools use this environment variable, for example, oh-my-posh will take "test_venv/" as virtual environment name rather than "test_venv"(Although venv's activate.ps 1 itself's default prompt is correct). And from the perspective of semantics and consistency with other platform, the '/' is redundant.

components: Library (Lib)
messages: 361094
nosy: Schwarzichet
priority: normal
severity: normal
status: open
title: redundant ‘/’ in $env:VIRTUAL_ENV when use venv in powershell
type: behavior
versions: Python 3.8, Python 3.9

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list