Saturday, August 20, 2011

cygwin terminal backspace problem

You just installed cygwin and opened a terminal to use it. If you see that backspace and delete keys does not work in terminal; instead the cursor moves ahead with space. It is strange that initial installation of cygwin has such weird problem. When i face this problem and googled to solve it, nothing worked actually.

Problem was that terminfo files used to define/configure terminal types (vt100, xterm etc.) were not available at expected directory; actually files were installed and existed in C:\cygwin\usr\share\terminfo but were not used by cygwin somehow.

Here is how to resolve it:

1- confirm that problem is terminal type related; run less command for that, it will give a warning:

bash-3.2$ less my_session.log
WARNING: terminal is not fully functional



2- run "infocmp -C" command to learn which path/directory is searched for termcap files:

bash-3.2$ infocmp -C
infocmp: couldn't open terminfo file /usr/share/terminfo/63/cygwin.
bash-3.2$


3- run "cygcheck -s" cygwin configuration diagnostics to learn some path details about /usr/share/terminfo.

bash-3.2$ cygcheck -s

Cygwin Configuration Diagnostics


...
C:/Program Files/ICW               /                    system  binary,noacl

C:/Program Files/ICW/bin           /usr/bin             system  binary,noacl
C:/Program Files/ICW/lib           /usr/lib             system  binary,noacl

C:\Program Files\ICW\etc\terminfo  /usr/share/terminfo  system  binary,noacl
cygdrive prefix                    /cygdrive            user    binary,noacl,posix=0,auto

...

4- copy missing files from /usr/share/terminfo to related directory C:\Program Files\ICW\etc\terminfo; target directory might be different; it depends on windows version and cygwin installation place; below is just two examples for target directories in my test case:

copy C:\Program Files\ICW\usr\share\terminfo directory/files to C:\Program Files\ICW\etc\terminfo or sometimes to C:\Users\<your_username>\AppData\Local\VirtualStore\Program Files\ICW\etc\terminfo

that's it!

3 comments:

  1. Ok, I had this issue with manually updating a Cygwin install. The older cygwin had a file /etc/terminfo/c/cygwin, but in the newer cygwin it expected the file to be /etc/terminfo/63/cygwin. Once I copied the "cygwin" file to this location, the bash shell backspace key worked fine, as did tab and others.

    ReplyDelete
  2. awesome.. totally solved my problem!
    originally, my cygcheck shows "incomplete" instead of "OK", as shown:
    terminfo 6.0-7.20160806 OK

    Mine used the default install folder of C:\cygwin64 so i just copied the /usr/share/terminfo folder (and all the subfolders) to /etc/terminfo. restarted Mintty and voila!

    ReplyDelete
  3. Thanks a lot.. you saved my life.. I was almost wanted to delte this CYGWIN

    ReplyDelete