poetry shell fails to set Python path if prompt uses VT100 escape sequences to read terminal information
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
Hướng nghiên cứu
Bắt đầu từ điểm vào poetry shell và theo dõi cách pexpect khởi động shell rồi gửi lệnh kích hoạt môi trường ảo. Tái hiện lỗi với prompt hỗ trợ VT100 được hiển thị trong issue, sau đó xác minh rằng shell được kích hoạt chính xác mà không tiêu thụ một phần lệnh kích hoạt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
- Poetry version: 1.4.2
- Python version: 3.11.2
- OS version and name: Ubuntu 23.04
- I am on the latest stable Poetry version, installed using a recommended method.
- I have searched the issues of this repo and believe that this is not a duplicate.
- I have consulted the FAQ and blog for any relevant entries or release notes.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption) and have included the output below.
Issue
Related: https://github.com/python-poetry/poetry-plugin-shell/issues/18 https://github.com/python-poetry/poetry/issues/571
This is a result of me diagnosing why poetry shell starts a new shell, but without the virtual env activated.
Looking at how poetry uses the shell, it uses pexpect to run it, writing the command to activate the python environment as its first input. This breaks in all configurations that read anything before that; particularly, any configuration that uses VT100 escape sequences that read anything. These may be more or less common in, for example, prompts.
For example, I have this in my .bashrc, essentially from this StackOverflow comment:
new_line_ps1() {
local _ y x _
local LIGHT_YELLOW="\001\033[1;93m\002"
local RESET="\001\e[0m\002"
IFS='[;' read -p $'\e[6n' -d R -rs _ y x _
if [[ "$x" != 1 ]]; then
printf "\n${LIGHT_YELLOW}^^ no newline at end of output ^^\n${RESET}"
fi
}
if [ "$color_prompt" = yes ]; then
PS1='$(new_line_ps1)${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='$(new_line_ps1)${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
My analysis of what happens:
What this prompt does is it outputs the "\e[6n" VT100 escape code to read cursor position. VT100 compliant terminals respond to this by producing the a string like "\e[10;1R" as if input from a keyboard. This can then be read by the program to determine that the cursor is on line 10, column 1.
The way poetry shell is implemented, it typically claims to be VT100 compliant if run from such a terminal (because it does not change the TERM environment variable), yet it does not respond to VT100 queries the shell outputs before giving it the activation command. In this case, that results in the read command in the prompt reading (part of) the activation command.
- 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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python-poetry/poetry-plugin-shell
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 20/100
python-poetry/poetry-plugin-shell#43 · 1 bình luận · 1 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
python-poetry/poetry-plugin-shell#42 · 4 bình luận · 15 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 38/100
python-poetry/poetry-plugin-shell#40 · 4 bình luận · 2 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
python-poetry/poetry-plugin-shell#37 · 3 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
python-poetry/poetry-plugin-shell#34 · 1 bình luận ·
Tất cả issue của python-poetry/poetry-plugin-shell
Issue tương tự
-
ACK_WAITING HELP_WANTED UPDATE_CS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OWASP/CheatSheetSeries#2458 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
BasedHardware/omi#19711 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Qwen3_5MoeModel no longer returns router_logits, breaking aux loss with output_router_logits=TrueĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
huggingface/transformers#49172 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
vllm-project/vllm-metal#885 ·
Maintainer thường phản hồi trong vòng 1 ngày