poetry shell fails to set Python path if prompt uses VT100 escape sequences to read terminal information
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Comienza en el punto de entrada poetry shell y sigue cómo pexpect inicia el shell y envía el comando de activación del entorno virtual. Reproduce el fallo con el prompt habilitado para VT100 mostrado en el issue y verifica que el shell se active correctamente sin consumir parte del comando de activación.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
- 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.
- Lenguaje dominante
- Python
- Estrellas
- 141
- Forks
- 10
- Merge medio
- 59 min
- PR fusionados (30 d)
- 3
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de python-poetry/poetry-plugin-shell
-
Dificultad 4/5 3-5 días Aptitud para principiantes 20/100
python-poetry/poetry-plugin-shell#43 · 1 comentario · 1 reacción ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
python-poetry/poetry-plugin-shell#42 · 4 comentarios · 15 reacciones ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 38/100
python-poetry/poetry-plugin-shell#40 · 4 comentarios · 2 reacciones ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
python-poetry/poetry-plugin-shell#37 · 3 comentarios ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 25/100
python-poetry/poetry-plugin-shell#34 · 1 comentario ·
Todos los issues de python-poetry/poetry-plugin-shell
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
BasedHardware/omi#20271 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 92/100
openai/openai-cookbook#3153 ·
Los mantenedores suelen responder en 1 día
-
cvss-severity:high devguard l3montree-cybersecurity/devguard/devguard pkg:golang/github.com/l3montree-dev/devguard risk:low state:open
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
l3montree-dev/devguard#3146 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
bug confirmed issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
open-webui/open-webui#31849 · 2 comentarios ·
Los mantenedores suelen responder en 1 día