nano error: Error opening terminal: xterm-256color

TerminalNano

Terminal Problem Overview


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?

Terminal Solutions


Solution 1 - Terminal

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 - Terminal

> 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 - Terminal

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 - Terminal

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.

Solution 5 - Terminal

I had this problem connecting to http://sdf.org through Mac OS X Lion. I changed under Terminal Preferences (+,) > Advanced pane, Declare Terminal as to VT-100.

I also marked Delete Sends Ctrl-H because this Mac connection was confusing zsh.

It appears to be working for my use case.

Solution 6 - Terminal

  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

  1. finally

    run:

    source .bash_profile

Solution 7 - Terminal

somehow and sometimes "terminfo" folder comes corrupted after a fresh installation. i don't know why, but the problem can be solved in this way:

1. Download Lion Installer from the App Store
2. Download unpkg: http://www.macupdate.com/app/mac/16357/unpkg
3. Open Lion Installer app in Finder (Right click -> Show Package
Contents)
4. Open InstallESD.dmg (under SharedSupport)
5. Unpack BSD.pkg with unpkg (Located under Packages)   Term info
will be located in the new BSD folder in /usr/share/terminfo

hope it helps.

Solution 8 - Terminal

Mine was quite a unique case but this could help someone. On Android I tried to copy nano from my termux binary folder to /system/xbin. Placed all the library dependencies in /system/lib and got this error. The libncurses.so.6 file I copied from termux had it's TERMINFO file still pointed to /data/data/com.termux/files/usr/share/terminfo

View pointed path with command

strings path-to-libncurses.so | grep /terminfo

To fix either make the termux terminfo dir and subdirs readable and executable by the nano user or copy the terminfo folder somewhere else and use a hexeditor to modify the plain text path in the shared library file.

Link to zipped terminfo folder https://drive.google.com/file/d/1m1tfHgkGRehBGh1jPMK4EaTgQb9EyCG7/view?usp=drivesdk

Solution 9 - Terminal

I hear that this can be fixed by overwriting your /usr/share/terminfo with one from the computer of somebody with a working install of Lion. I can't confirm whether this works or not, and unfortunately I haven't upgraded yet, so I can't provide you with that file.

Solution 10 - Terminal

You can add the following in your .bashrc

if [ "$TERM" = xterm ]; then TERM=xterm-256color; fi

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLukeView Question on Stackoverflow
Solution 1 - TerminalMeetai.comView Answer on Stackoverflow
Solution 2 - TerminalcalvinfView Answer on Stackoverflow
Solution 3 - TerminalJohnnyView Answer on Stackoverflow
Solution 4 - TerminalbitaxisView Answer on Stackoverflow
Solution 5 - TerminalisomorphismesView Answer on Stackoverflow
Solution 6 - TerminalXu RadmanView Answer on Stackoverflow
Solution 7 - TerminalLukeView Answer on Stackoverflow
Solution 8 - TerminalFortuneView Answer on Stackoverflow
Solution 9 - TerminalEdoDodoView Answer on Stackoverflow
Solution 10 - Terminaldoesnt_matterView Answer on Stackoverflow