Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Poetry does not automatically switch venvs in venv-activated shells

Aperta
#19 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
fish, python
Ambito
cli

Direzione di ricerca

Inizia riproducendo il flusso segnalato con poetry shell, cd tra i due progetti e poetry env info in una shell fish su Ubuntu. La modifica è completata quando spostandosi tra i progetti viene selezionato automaticamente l’ambiente virtuale corrispondente e il prompt della shell lo riflette, senza richiedere poetry env use python.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Ubuntu 20.04.2 LTS
  • Poetry version: 1.1.16

Issue

Create two blank projects

/t/test> poetry new a
Created package a in a
/t/test> poetry new b
Created package b in b
/t/test> cd a

Create a's venv

/t/t/a> poetry shell
Creating virtualenv a-sARTaVSs-py3.8 in ~/.cache/pypoetry/virtualenvs
Spawning shell within ~/.cache/pypoetry/virtualenvs/a-sARTaVSs-py3.8
source ~/.cache/pypoetry/virtualenvs/a-sARTaVSs-py3.8/bin/activate.fish
Welcome to fish, the friendly interactive shell
Type `help` for instructions on how to use fish
(a-sARTaVSs-py3.8)  /t/t/a> exit

We quitted a's venv, now create b's

/t/t/a> cd ../b
/t/t/b> poetry shell
Creating virtualenv b-Eo6UuKir-py3.8 in ~/.cache/pypoetry/virtualenvs
Spawning shell within ~/.cache/pypoetry/virtualenvs/b-Eo6UuKir-py3.8
source ~/.cache/pypoetry/virtualenvs/b-Eo6UuKir-py3.8/bin/activate.fish
Welcome to fish, the friendly interactive shell
Type `help` for instructions on how to use fish

We're still in b's venv, now let's go to a's project

(b-Eo6UuKir-py3.8) /t/t/b> cd ../a
(b-Eo6UuKir-py3.8) /t/t/a> poetry env info

Virtualenv
Python:         3.8.5
Implementation: CPython
Path:           ~/.cache/pypoetry/virtualenvs/b-Eo6UuKir-py3.8
Valid:          True

System
Platform: linux
OS:       posix
Python:   /usr

Crap, we are still in b's venv... If we run poetry install we'll install a's dependencies in b's venv
But there is a way out, eventhough the prompt is wrong (should be a-sARTaVSs-py3.8)

(b-Eo6UuKir-py3.8) /t/t/a> poetry env use python
Using virtualenv: ~/.cache/pypoetry/virtualenvs/a-sARTaVSs-py3.8
(b-Eo6UuKir-py3.8) /t/t/a> poetry env info

Virtualenv
Python:         3.8.5
Implementation: CPython
Path:           ~/.cache/pypoetry/virtualenvs/a-sARTaVSs-py3.8
Valid:          True

System
Platform: linux
OS:       posix
Python:   /usr

Now we are in a's venv (the right one), let's go back to b's project folder

(b-Eo6UuKir-py3.8) /t/t/a> cd ../b
(b-Eo6UuKir-py3.8) /t/t/b> poetry env info

Virtualenv
Python:         3.8.5
Implementation: CPython
Path:           ~/.cache/pypoetry/virtualenvs/b-Eo6UuKir-py3.8
Valid:          True

System
Platform: linux
OS:       posix
Python:   /usr

Surprisingly, on the way back everything is alright

Lingua principale
Python
Stelle
141
Fork
10
Merge medio
59m
PR unite (30g)
3

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python-poetry/poetry-plugin-shell

Tutte le issue di python-poetry/poetry-plugin-shell

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.