Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Poetry does not automatically switch venvs in venv-activated shells

Đang mở
#19 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
fish, python
Lĩnh vực
cli

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện quy trình đã được báo cáo với poetry shell, cd giữa hai dự án và poetry env info trong một shell fish trên Ubuntu. Thay đổi được hoàn tất khi việc chuyển đổi giữa các dự án tự động chọn môi trường ảo tương ứng và dấu nhắc shell phản ánh điều đó, mà không cần poetry env use python.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

  • 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

Ngôn ngữ chính
Python
Star
141
Fork
10
Merge trung bình
59 phút
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của python-poetry/poetry-plugin-shell

Tất cả issue của python-poetry/poetry-plugin-shell

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.