poetry shell fails to set Python path if prompt uses VT100 escape sequences to read terminal information
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia dal punto di ingresso poetry shell e traccia il modo in cui pexpect avvia la shell e invia il comando di attivazione dell’ambiente virtuale. Riproduci il problema con il prompt abilitato per VT100 mostrato nell’issue, quindi verifica che la shell si attivi correttamente senza consumare parte del comando di attivazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
- 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.
- Lingua principale
- Python
- Stelle
- 141
- Fork
- 10
- Merge medio
- 59m
- PR unite (30g)
- 3
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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.
Altre issue di python-poetry/poetry-plugin-shell
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
python-poetry/poetry-plugin-shell#43 · 1 commento · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
python-poetry/poetry-plugin-shell#42 · 4 commenti · 15 reazioni ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 38/100
python-poetry/poetry-plugin-shell#40 · 4 commenti · 2 reazioni ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
python-poetry/poetry-plugin-shell#37 · 3 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 25/100
python-poetry/poetry-plugin-shell#34 · 1 commento ·
Tutte le issue di python-poetry/poetry-plugin-shell
Issue simili
-
🐛 Bug: Calendar work items cannot be opened on mobileForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
Status: Triage Type: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
-
Objects.List treats versions=false (and similar flags) as trueForse già presa @andaaron l’ha presa oggi. Apertapriority: p2 type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
googleapis/storage-testbench#829 ·
I maintainer di solito rispondono entro 2 giorni
-
[Bug]: memory provider treats 1:1 DMs as shared surfaces, so DM turns never receive reviewed recordsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
rlaope/oh-my-hermes#2088 ·
I maintainer di solito rispondono entro 1 giorno