poetry: Shell prompt stops responding to terminal resize event after `poetry shell`

  • 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: KDE neon 5.25 (based on Ubuntu 20.04.1 LTS) fully up-to-date.
  • Poetry version: 1.2.0
  • Terminal used: Konsole 22.08.0

Issue

Steps to reproduce:

  1. Set up a zsh shell with oh-my-zsh installed. Any theme would do, but for ease of viewing, set ZSH_THEME in .zshrc to "dst".
  2. Resize the terminal without being inside poetry shell.
  3. Enter poetry shell. Resize the terminal.

Expected behaviour: The prompt responds normally to terminal resize events.

Actual behaviour: The prompt does not respond to terminal resize events. What

Notes:

  • Only zsh with oh-my-zsh has been tested
  • Only tested on Konsole terminal, other terminals have not been tested
  • This issue does not occur on v1.1.x releases of Poetry.
  • This affects only the prompt, writing to stdout is not affected

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 18 (8 by maintainers)

Most upvoted comments

The issue is known/solved on the 1.2 branch – the signal handler for SIGWINCH used a bogus/incorrect method to query the new window size (and thus passed a bad size to the child process). Please try the 1.2 branch and request a re-open if this can be reproduced there:

pipx install --suffix @b1.2 git+https://github.com/python-poetry/poetry@1.2

Change to shutil made it into the 1.2 release

This is not correct, you’ve linked to the branch (where the fix has been backported) but it did not make it to the 1.2.0 release - https://github.com/python-poetry/poetry/blob/1.2.0/src/poetry/utils/shell.py#L102

🤣 seems that I am blind. Good to know, I was going crazy trying to figure out why it breaks… So, basically, we are waiting for 1.2.1 release.

Poetry at 1.1.15 uses clikit’s Terminal implementation. Poetry at 1.2.0 updated to cleo’s Terminal

cleo’s terminal at 1.0.0a5 has a bug. clikit’s implmentation initializes the width and height as instance variables. cleo’s implementation at this version initializes the width and height as variables in the __class__ attribute. When terminal is reinstantiated, clikit’s version would reinitialize the width and height, but since cleo’s version is storing the variable in the __class__ attribute, which belongs to the class and not the object, it retains the settings from the original initialization.

This is fixed as of now in master, as per PR #6224, as cleo and poetry both replaced their implementation with calls using shutil, but remains an issue in the 1.2.0 release.

I believe this may be related to issue #4165.

Well, that last part is not true. Change to shutil made it into the 1.2 release: shell.py. I have been looking into what is happening here and my current guess is that somehow old Cleo approach with custom Terminal class, and the change in Poetry 1.2 to using shutil solution somehow conflict. I have yet to test it though. Also, with Cleo getting a 1.0 stable release pretty soon, it might resolve on its own with that change.