Poetry: bash shell does not echo typed characters

Created on 26 Oct 2019  路  7Comments  路  Source: python-poetry/poetry

  • [x] I am on the latest Poetry version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • openSUSE Linux 15.1
  • Poetry 1.0.0b3

Issue

The poetry shell command worked fine on my machine for Poetry 0.12.17, but after upgrading to Poetry 1.0.0b3, when I get the shell prompt after running the poetry shell command, the terminal output is broken. The most striking problem is that characters I type are not echoed, but there are other output glitches as well:

poetry@hyperion:~/retroasm> poetry shell
/home/poetry/.poetry/lib/poetry/_vendor/py2.7/subprocess32.py:149: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your program uses threads.
  "program uses threads.", RuntimeWarning)
The currently activated Python version 2.7.14 is not supported by the project (^3.6).
Trying to find and use a compatible version. 
Using python3 (3.6.5)
Spawning shell within /home/poetry/.cache/pypoetry/virtualenvs/retroasm-MmrMfn3P-py3.6
poetry@hyperion:~/retroasm> (retroasm-MmrMfn3P-py3.6) poetry@hyperion:~/retroasm

At this point, I can type commands and they are executed, but I don't see any of the characters I type echoed after the prompt. After running reset my typed input is echoed again.

Note the missing newline at end: that is not a copy-paste error, that actually happens in the terminal. When I execute a command like ls -1, the newline from typing the command does not appear, but the newlines printed by ls do:

(retroasm-MmrMfn3P-py3.6) poetry@hyperion:~/retroasm> LICENSE
README.md
checkdef.py
(snip)

I thought the problem might have to do with the ANSI codes used to produce colors, but while poetry shell --no-ansi does suppress the color output, it doesn't fix the problem.

The problem is specific to bash: if I start a different shell, it works fine:

poetry@hyperion:~/retroasm> SHELL=ksh poetry shell
/home/poetry/.poetry/lib/poetry/_vendor/py2.7/subprocess32.py:149: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your program uses threads.
  "program uses threads.", RuntimeWarning)
The currently activated Python version 2.7.14 is not supported by the project (^3.6).
Trying to find and use a compatible version. 
Using python3 (3.6.5)
Spawning shell within /home/poetry/.cache/pypoetry/virtualenvs/retroasm-MmrMfn3P-py3.6
$ . /home/poetry/.cache/pypoetry/virtualenvs/retroasm-MmrMfn3P-py3.6/bin/activate
(retroasm-MmrMfn3P-py3.6) $ ls -1
LICENSE
README.md
(snip)

I have a git prompt and several completions configured for bash on my normal developer account, so to rule out that those are causing problems I created a new user account and disabled the systemwide bash configurations by renaming the /etc/aliases.d, /etc/bash_completion.d and /etc/profile.d directories. That didn't fix the problem.

I tried changing the TERM environment variable from xterm-256color to just xterm and to vt100, but that didn't fix the problem either.

At this point I'm out of ideas for what else I could be trying to diagnose this problem. If anyone has a clue, please comment.

Bug

Most helpful comment

I have the same problem, it seems to be introduced in Poetry 1.0.0b2

I can workaround it by blindly typing reset after entering the shell.

All 7 comments

I have the same problem, it seems to be introduced in Poetry 1.0.0b2

I can workaround it by blindly typing reset after entering the shell.

Thirding this problem. The bug is present in various Bash terminals, including the PyCharm one. Poetry 1.0.0b3 on Ubuntu 18. I can confirm the reset workaround, as well.

Did a bit of debugging... seems like a timing issue. In poetry/utils/shell.py Shell.activate() we call

c = pexpect.spawn(
                self._path, ["-i"], dimensions=(terminal.height, terminal.width)
            )
...
c.setecho(False)

Removing c.setecho(False) fixes it, but also putting a sleep of one second in before c.setecho(False) also fixes it. Not sure what the purpose of the code is here so can't really offer a fix but I guess some implicit assumption about how long it would take to spawn the shell is being violated.

Edit: I'm running poetry 1.0.0b3 on macOS 10.14.6 Mojave

Ping @sdispater about removing that sentence or delaying its execution a bit.

Also experiencing this problem with:

$ poetry --version
Poetry version 1.0.0b3

$ bash --version
GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:    18.04
Codename:   bionic

Also experiencing this with:

$ poetry --version
Poetry version 1.0.0b4

$ bash --version
GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 19.10
Release:    19.10
Codename:   eoan

The problem no longer occurs for me with Poetry 1.0.0b8, so it looks like the fix is working.

Was this page helpful?
0 / 5 - 0 ratings