nano error: Error opening terminal: xterm-256color

176,241

Solution 1

On Red Hat this worked for me:

export TERM=xterm

further info here: http://www.cloudfarm.it/fix-error-opening-terminal-xterm-256color-unknown-terminal-type/

Solution 2

After upgrading to OSX Lion, I started getting this error on certain (Debian/Ubuntu) servers. The fix is simply to install the “ncurses-term” package which provides the file /usr/share/terminfo/x/xterm-256color.

This worked for me on a Ubuntu server, via Erik Osterman.

Solution 3

I can confirm this is a terminfo issue. This is what worked for me. SSH in to the remote machine and run

 sudo apt-get install ncurses-term

Boom. Problem solved.

Solution 4

  1. edit your .bash_profile file

    vim .bash_profile

  2. commnet

    #export TERM=xterm-256color

  3. add this

    export TERMINFO=/usr/share/terminfo

    export TERM=xterm-basic

    to your .bash_profile

  4. finally

    run:

    source .bash_profile

Solution 5

I, too, have this problem on an older Mac that I upgraded to Lion.

Before reading the terminfo tip, I was able to get vi and less working by doing "export TERM=xterm".

After reading the tip, I grabbed /usr/share/terminfo from a newer Mac that has fresh install of Lion and does not exhibit this problem.

Now, even though echo $TERM still yields xterm-256color, vi and less now work fine.

Share:
176,241
Luke
Author by

Luke

Updated on September 21, 2021

Comments

  • Luke
    Luke over 1 year

    After the installation of OSX Lion, I tried to:

    nano /etc/apt/sources.list
    

    But I get this error:

    Error opening terminal: xterm-256color
    

    If I try to switch terminal.app preferences to open terminal windows in "xterm color" instead of xterm-256color everything works fine.

    What's happening?

  • Mike Lawrence
    Mike Lawrence almost 12 years
    I encountered the same error and tried your suggested steps. I encountered a number of permission denied errors while unpacking with unpkg. The BSD folder appeared on my desktop, and I ran "sudo mv ~/Desktop/BSD/usr/share/terminfo /usr/share/terminfo" then restarted terminal, but I still get the same "Error opening terminal: xterm-256color" error.
  • Luke
    Luke almost 12 years
    maybe you can try this sendspace.com/file/hc2dus it's my terminfo folder. after replacing it, don't forget to chmod 555 /usr/share/terminfo
  • DOOManiac
    DOOManiac over 9 years
    Thanks for an answer that did NOT involve changing the server!
  • Nicolas Barbulesco
    Nicolas Barbulesco over 8 years
    This does not work for me. I connect from a Mac in Mavericks to a Mac in Snow Leopard. I get the error when I launch top.
  • isomorphismes
    isomorphismes over 8 years
    @NicolasBarbulesco Ah ok Nicolas, sorry but I'm no longer using Mac so I can't test this with you.
  • Ryan Griffith
    Ryan Griffith almost 7 years
    Worked for me when ran on the remove system. Connection from was OS X -> Ubuntu
  • shevy
    shevy over 6 years
    Interestingly, I had this error in a chroot-ed environment that has only minimal programs so far. I assume that there is some program missing that causes this, but unfortunately nano does not give more information as to why it exactly fails.
  • shevy
    shevy over 6 years
    I think this may be one reason why nano may sometimes fail - e. g. if the problem happens at ncurses/terminfo instead.
  • Henning
    Henning almost 6 years
    Works also when trying to use top inside a minikube local kubernetes system running as a VM based on buildroot inside Virtualbox on Max OS X. (which is ssh from MacOS into a Buildroot based VM and tgen run top)
  • Meetai.com
    Meetai.com over 5 years
    The same solution seems correct for different systems, including Ubuntu/Debian and OSX (the OP's). How is this irrelevant?
  • inspirednz
    inspirednz almost 5 years
    This worked for me on a Debian system. How do I make this permanent? Such as having it occur when I log in via SSH?
  • das-g
    das-g over 4 years
    While this may work (and even more generically than the "real" solutions) it's conceptually a workaround at best. You're essentially lying to your shell about the terminal you use to connect.
  • Admin
    Admin over 4 years
    For anyone trying to get a chroot running on macOS, this fixes "Error opening terminal: " issue inside the chroot.
  • Meetai.com
    Meetai.com over 4 years
    It might be a "hack" that sheds light in the underlying issue.
  • XavierStuvw
    XavierStuvw over 3 years
    This worked for me when ccmake, instead of nano, was issuing the same error message
  • Gayan Kavirathne
    Gayan Kavirathne almost 3 years
    I ran to a similar situation when uding a chroot ssh configuration. And I fixed it as @Fortune has menstioned. find and copy terminfo folders to the chroot folder structure