Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

poetry shell loses terminal lines and columns (stuck at 80x25) #4165

Closed
2 of 3 tasks
mmessmore opened this issue Jun 9, 2021 · 7 comments
Closed
2 of 3 tasks

poetry shell loses terminal lines and columns (stuck at 80x25) #4165

mmessmore opened this issue Jun 9, 2021 · 7 comments
Labels
kind/bug Something isn't working as expected

Comments

@mmessmore
Copy link

  • 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). (n/a)

  • OS version and name: FreeBSD 13.0

  • Poetry version: 1.1.16

Issue

When running poetry shell my terminal is set to 80x25 regardless of window size. This was originally noticed within tmux, but is reproducible in plain konsole and xterm.

I'll provide an example from xterm because it's the most "normal".

$ tput cols
141
$ tput lines
45
$ poetry shell
Spawning shell within /home/mike/.cache/pypoetry/virtualenvs/arsenal-Cu8X-dwc-py3.9
(arsenal-Cu8X-dwc-py3.9) $ tput cols
80
(arsenal-Cu8X-dwc-py3.9) $ tput lines
25
(arsenal-Cu8X-dwc-py3.9) $ poetry --version
Poetry version 1.1.6
(arsenal-Cu8X-dwc-py3.9) $ echo $TERM
xterm

It causes weird behavior in neovim, less, etc. unless the window is sized to 80x25, which is not ideal.

Manually sourcing the virtualenv does not cause this

$ source `poetry env info --path`/bin/activate
(arsenal-Cu8X-dwc-py3.9) $ tput cols
141
(arsenal-Cu8X-dwc-py3.9) $ tput lines
45

And as a side note, with other projects managed by pipenv, this does not occur in pipenv shell. Not trying to be inflammatory. I just wanted to note it since it too uses a subshell, but created differently.

I'm sorry that I don't have a solution to propose or associated PR, as this defies my limited understanding of termcap. I will attempt further research as I have time, but wanted to file this now.

@mmessmore mmessmore added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jun 9, 2021
@kovasap
Copy link

kovasap commented Jun 20, 2021

This might be related to #4121.

@mmessmore
Copy link
Author

Yes, it does appear to be the same. But it's that the terminal dimensions are lost. 'termcap' is a misnomer in my title, as I jumped through hoops and recreated it with 'terminfo'. And now I'm not sure if it's a 'tty' thing or an 'X11' thing. I'll update my title if I can to be more generic.

On a whim, I've tried manually sending the processes in the tree a SIGWINCH to see if I could get it to do something with the X window dimensions side of things. It doesn't die, but it doesn't change anything either.

After more exploring, I don't have the issue via poetry run. I can run poetry run vim and it will resize fine with the window.
A more concrete example:

$ poetry run tput cols
116
$ poetry run tput lines
40

@mmessmore mmessmore changed the title poetry shell breaks termcap poetry shell loses terminal lines and columns (stuck at 80x25) Jun 22, 2021
@icodeforyou-dot-net
Copy link

I am also experiencing this on FreeBSD 13.1 in alacritty on X11 running bspwm and picom. Any development on this issue in the last year?

@icodeforyou-dot-net
Copy link

A potential workaround, depending on what you are looking for, might be to activate the environment using a shell function defined in .bashrc or wherever you like. Like so:

function poetry_activate() {
  if [[ -f "pyproject.toml" ]]; then
    # check if already in virtualenv
    command -v deactivate &> /dev/null && deactivate

    poetry_env=$(poetry env info -p)
    source "$poetry_env/bin/activate"
  fi
}

(Partially modified from here: https://github.com/tvaintrob/auto-poetry-env/blob/main/auto-poetry-env.sh)

I am wondering whether this issue is somehow related to the fact that we are both running FreeBSD...

@max-sixty
Copy link
Contributor

Something I'm experimenting with is only running the activate script at /Users/{user}/Library/Caches/pypoetry/virtualenvs/{proj}-x204KUJE-py3.9/bin/.

That seems to give the necessary shell configs without the resize etc at https://github.com/python-poetry/poetry/blob/c1475a0b6dd6f4a3e99112cc36b8c0d1024e4048/src/poetry/utils/shell.py.

That said — am I missing something? Why do we need the python code there?

@neersighted
Copy link
Member

Dupe #6351

@neersighted neersighted closed this as not planned Won't fix, can't repro, duplicate, stale Sep 14, 2022
@mkniewallner mkniewallner removed the status/triage This issue needs to be triaged label Sep 18, 2022
Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

6 participants