MSYS2-packages: Arrow keys and backspace not working in bash after recent update

Today I ran pacman -Syu which upgraded the following packages (from the end of /var/log/pacman.log):

[2018-01-30 11:56] [ALPM] upgraded mpfr (3.1.5.1-3 -> 4.0.0.1-3)
[2018-01-30 11:56] [ALPM] upgraded gcc-libs (6.4.0-1 -> 6.4.0-2)
[2018-01-30 11:56] [ALPM] upgraded ncurses (6.0.20170708-2 -> 6.1.20180127-1)
[2018-01-30 11:56] [ALPM] upgraded gawk (4.1.4-2 -> 4.2.0-1)
[2018-01-30 11:56] [ALPM] upgraded isl (0.16.1-1 -> 0.18-1)
[2018-01-30 11:56] [ALPM] upgraded mpc (1.0.3-1 -> 1.1.0-1)
[2018-01-30 11:56] [ALPM] upgraded msys2-w32api-headers (5.0.0.4961.e09dd4ca-1 -> 6.0.0.5097.36d7b92b-1)
[2018-01-30 11:56] [ALPM] upgraded msys2-w32api-runtime (5.0.0.4961.e09dd4ca-1 -> 6.0.0.5097.36d7b92b-1)
[2018-01-30 11:56] [ALPM] upgraded gcc (6.4.0-1 -> 6.4.0-2)
[2018-01-30 11:56] [ALPM] upgraded ncurses-devel (6.0.20170708-2 -> 6.1.20180127-1)
[2018-01-30 11:56] [ALPM] upgraded wget (1.19.2-1 -> 1.19.3-1)

After this update the arrow keys and backspace don’t work correctly at the shell input line, in a weird way.

I tried the following with and without a ~/.bashrc file:

Pressing few chars and then a backspace seems to print a space. Up arrow works but then the shell doesn’t clean up the line with history inputs and just appends the history items to the line.

Left and right arrows at the shell prompt don’t skip chars as expected, but ctrl-v and then pressing an arrow key does print a correct (I think) string, e.g. ctrl-v and then right arrow prints ^[[C but the shell doesn’t seem to re-render the line correctly when used without it.

Up/down/left/right arrows while in less (/usr/bin/less) does seem to work correctly.

It’s like the shell reads the keys correctly but not able to re-render the input line correctly. Maybe the ncurses update is at fault?

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 4
  • Comments: 38 (14 by maintainers)

Commits related to this issue

Most upvoted comments

I do have the described issues as well. Changing TERM (e.g. to ansi) seems to fix everything, but it’s weirder than that:

ether@jolteon MSYS /w
$ echo $TERM
xterm-256color

ether@jolteon MSYS /w
[broken rendering]

ether@jolteon MSYS /w
$ TERM=xterm-256color

ether@jolteon MSYS /w
[still broken rendering]

ether@jolteon MSYS /w
$ TERM=xterm

ether@jolteon MSYS /w
[rendering fine]

ether@jolteon MSYS /w
$ TERM=xterm-256color

ether@jolteon MSYS /w
[rendering still fine]

– David Macek

Just happened for me as well. Downgrading ncurses solved it for me.

I checked my /var/log/pacman.log which ended with:

[2018-01-15 09:48] [PACMAN] Running 'pacman -Syu'
[2018-01-15 09:48] [PACMAN] synchronizing package lists
[2018-01-15 09:48] [PACMAN] starting core system upgrade
[2018-01-15 09:49] [ALPM] transaction started
[2018-01-15 09:49] [ALPM] upgraded mintty (1~2.8.1-1 -> 1~2.8.3-1)
[2018-01-15 09:49] [ALPM] transaction completed
[2018-01-15 09:49] [PACMAN] Running 'pacman -Syu'
[2018-01-15 09:49] [PACMAN] synchronizing package lists
[2018-01-15 09:49] [PACMAN] starting core system upgrade
[2018-01-15 09:49] [PACMAN] starting full system upgrade
[2018-01-15 09:49] [ALPM] transaction started
[2018-01-15 09:49] [ALPM] removed tmux-git (2.5.94.g73b9328c-1)
[2018-01-15 09:49] [ALPM] upgraded gzip (1.8-1 -> 1.9-1)
[2018-01-15 09:49] [ALPM] installed tmux (2.6-1)
[2018-01-15 09:49] [ALPM] upgraded wget (1.19.1-3 -> 1.19.2-1)
[2018-01-15 09:49] [ALPM] transaction completed
[2018-01-15 09:49] [PACMAN] Running 'pacman -Syu'
[2018-01-15 09:49] [PACMAN] synchronizing package lists
[2018-01-15 09:49] [PACMAN] starting core system upgrade
[2018-01-15 09:49] [PACMAN] starting full system upgrade
[2018-01-30 11:17] [PACMAN] Running 'pacman -Syu'
[2018-01-30 11:17] [PACMAN] synchronizing package lists
[2018-01-30 11:17] [PACMAN] starting core system upgrade
[2018-01-30 11:17] [PACMAN] starting full system upgrade
[2018-01-30 11:19] [ALPM] transaction started
[2018-01-30 11:19] [ALPM] upgraded mpfr (3.1.5.1-3 -> 4.0.0.1-3)
[2018-01-30 11:19] [ALPM] upgraded gcc-libs (6.4.0-1 -> 6.4.0-2)
[2018-01-30 11:20] [ALPM] upgraded ncurses (6.0.20170708-2 -> 6.1.20180127-1)
[2018-01-30 11:20] [ALPM] upgraded gawk (4.1.4-2 -> 4.2.0-1)
[2018-01-30 11:20] [ALPM] upgraded isl (0.16.1-1 -> 0.18-1)
[2018-01-30 11:20] [ALPM] upgraded mpc (1.0.3-1 -> 1.1.0-1)
[2018-01-30 11:20] [ALPM] upgraded msys2-w32api-headers (5.0.0.4961.e09dd4ca-1 -> 6.0.0.5097.36d7b92b-1)
[2018-01-30 11:20] [ALPM] upgraded msys2-w32api-runtime (5.0.0.4961.e09dd4ca-1 -> 6.0.0.5097.36d7b92b-1)
[2018-01-30 11:20] [ALPM] upgraded gcc (6.4.0-1 -> 6.4.0-2)
[2018-01-30 11:20] [ALPM] upgraded openssh (7.5p1-1 -> 7.6p1-1)
[2018-01-30 11:20] [ALPM] upgraded git (2.15.0-1 -> 2.16.1-1)
[2018-01-30 11:20] [ALPM] upgraded tzcode (2017.b-1 -> 2018.c-1)
[2018-01-30 11:20] [ALPM] upgraded wget (1.19.2-1 -> 1.19.3-1)
[2018-01-30 11:20] [ALPM] transaction completed

So, somewhere between 2018-01-15 and 2018-01-30 this regression happened. ncurses seemed like the most suspicious upgrade, so I downgraded (see instructions on how to ignore package upgrades for certain packages) through:

pacman -U /var/cache/pacman/pkg/ncurses-6.0.20170708-2-x86_64.pkg.tar.xz

and in the next MSYS2 instance I started, terminal codes for backspace, delete, etc., worked as intended again.

I tried checking the Backarrow sends ^H and Delete sends DEL settings in “broken” mode, but it did not seem to help, instead doing nothing when pressing those characters, if I recall correctly.

I am using TERM=xterm-256color.

#1128

Assuming ncurses 6.1 may break binary compatibility, it would need a rebuild of all packages which use ncurses. Bash is just the most visible of those (assuming there are more packages depending on ncurses).

Rebuild bash can fix the problem. Thank you for the information.

You could try the rebuilded bash at

https://ci.appveyor.com/project/zklhp/msys2-packages/build/1.0.16/artifacts

Deleting ~/.minttyrc helped here (or I was just lucky and that was unrelated…)

It’s because the default mintty TERM is xterm, and the issue appears to be related to TERM being xterm-256color - which is required for some programs to display more than 8 colors.

FWIW, my original /usr/bin/bash.exe is from 2017-02-15, so almost a year old, and building a fresh one (same version 4.4.12(1)-release (x86_64-pc-msys), using makepkg) did fix it for me. I also know of other people bumping into this issue, which, again, is quite a dealbreaker.