Windows virtual environment does not work correctly under WSL
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug report
Bug description:
Currently, Windows venvs work under cygwin because the activate script checks for it and converts the path as necessary. Cygwin is old and the new way to run a Linux shell on Windows is through the Windows Subsystem for Linux (WSL). However, there is no check for it in the script, making it not work correctly.
The relevant snippet from the script is:
# on Windows, a path can contain colons and backslashes and has to be converted:
case "$(uname)" in
CYGWIN*|MSYS*)
# transform D:\path\to\venv to /d/path/to/venv on MSYS
# and to /cygdrive/d/path/to/venv on Cygwin
VIRTUAL_ENV=$(cygpath "__VENV_DIR__")
export VIRTUAL_ENV
;;
*)
# use the path as-is
export VIRTUAL_ENV="__VENV_DIR__"
;;
esac
I was able to easily fix it manually by changing the reference to my project's venv path with $(wslpath -u "__VENV_DIR__"). All we need is a check for WSL in the script and another prong on this case statement. The best way to do this is probably by searching for "microsoft" or "wsl" in the output of uname -r. Some work might be needed to ensure this covers all edge cases.
CPython versions tested on:
3.12
Operating systems tested on:
Windows
Linked PRs
- gh-124155
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Individua lo script di attivazione di venv contenente l’istruzione case di uname mostrata e confrontane il comportamento in WSL con i rami Cygwin e MSYS esistenti. Controlla come wslpath gestisce il percorso della venv Windows, quindi verifica che l’attivazione di una venv Windows da WSL imposti il valore corretto di VIRTUAL_ENV e non introduca regressioni negli altri ambienti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python, shell
- Ambito
- operating-systems, tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100