21

When I try to nano something on my server I'm getting this error "Error opening terminal: xterm-256color." that I've never seen before, and on top of that nano used to work fine last week. Even when I use vi, the file will open but I can't manipulate using normal vi commands. When I press i to activate insert mode and then try to navigate the document, it just types an A or B or something.

The only thing that changed is I lost my private key and had to generate a new one, so I had to upload the new public key to my server. Anyone know why this is happening?

The server is running Ubuntu 8.04 Hardy.


SOLUTION

Open Terminal, select from the menu Terminal > Preferences > Settings > Advanced and under Emulation select "Declare terminal as: xterm-color not xterm-256color"

Reference: http://ricochen.wordpress.com/2011/07/23/mac-os-x-lion-terminal-color-remote-access-problem-fix/

JJD
  • 50,076
  • 60
  • 203
  • 339
GiH
  • 14,006
  • 13
  • 43
  • 56
  • 2
    As of Mac OS X Lion 10.7, Terminal's default $TERM value is xterm-256color. (Prior to Lion it was xterm-color.) If you're connecting to a remote host that doesn't have the necessary terminfo files installed, I recommend you install them. Selecting xterm-color is a workaround, but disables some important enhancements that are new in Lion Terminal. At the very least, you should try using xterm instead of xterm-color to see how that works for you, because xterm-color represents an older branch of xterm that isn't as capable as modern xterm. – Chris Page Aug 26 '11 at 01:11
  • how do we go about installing the necessary terminfo files then? – GiH Oct 02 '11 at 18:04
  • You should probably ask that as a separate question. (For the record, I'm unfamiliar with your system and don't know the answer for your situation.) – Chris Page Oct 03 '11 at 08:07

4 Answers4

9

xterm-256color is a reference to a terminfo entry. It should be in /usr/share/terminfo/x/. I believe in ubuntu, the package containing the file is ncurses-term.

If the file is corrupted or missing reinstalling the package should fix it. You can also take a look at the files /usr/share/terminfo and set your TERM variable to a supported emulation by your server (xterm is usually a good choice).

About why this happend, the file may be corrupted or missing (check your filesystem), but i think the most likely reason is you changed your terminal emulator or its settings.

Pablo Castellazzi
  • 4,164
  • 23
  • 20
  • thanks, do you have any resource on how to reinstall the package or setting the TERM variable? Ill give that a try – GiH Jul 23 '11 at 17:05
  • The [ubuntu server guide](https://help.ubuntu.com/10.04/serverguide/C/index.html) have a section about [package management](https://help.ubuntu.com/10.04/serverguide/C/package-management.html). TERM is an environment variable, is set by the shell, the default shell in Ubuntu is bash, you can find a guide to it [here](http://tldp.org/LDP/abs/html/) – Pablo Castellazzi Jul 23 '11 at 23:56
  • 2
    sudo apt-get install ncurses-term –  Mar 24 '12 at 21:58
  • In case you cannot find term-256color after installing ncurses-term then try gnome-256color and check it again with "tput color" – Uphill_ What '1 Jul 15 '13 at 11:49
3

Snow Leopard doesn't have the xterm-256color terminfo file in /usr/share/terminfo/78. A Lion upgrade will add it. An Xcode 3 to 4 upgrade will delete it (as well as 90% of the other terminfo files in /usr/share/terminfo/78 ). Time Machine backups in my case confirmed this peculiar chain of events.

If you use Time Machine you can restore the file. Set Finder to see UNIX files (at a command line, defaults write com.apple.finder AppleShowAllFiles True; killall Finder) or you won't be able to get to it.

jerseyboy
  • 1,298
  • 13
  • 13
2

Probably due to a Lion upgrade/install. Did you do that recently @Gih?

Possible duplicate (with fix) at nano error: Error opening terminal: xterm-256color

EDIT:

Easiest fix (takes 10 seconds)...from Michael:

There is a solution much easier: http://ricochen.wordpress.com/2011/07/23/mac-os-x-lion-terminal-color-remote-access-problem-fix/

Community
  • 1
  • 1
jbnunn
  • 6,161
  • 4
  • 40
  • 65
  • Worked :-), follow this link for the simplest solution http://ricochen.wordpress.com/2011/07/23/mac-os-x-lion-terminal-color-remote-access-problem-fix/, or follow the link in the answer for other options, ill leave this question open as i couldn't find the other one in my search so this might help – GiH Aug 12 '11 at 22:04
  • Note that this is a workaround, but may leave your computer in an undesirable state, because it's (apparently) missing some terminfo files. xterm-color represents an older branch of xterm with less functionality and is not recommended. You might also try "xterm" to see how that works for you, since it's overall a better representation of Lion Terminal's capabilities than is xterm-color. Fixing the problem requires installing the missing terminfo files. If the problem is occurring when connected to a remote host, then the terminfo files must be installed on that host, not your local Mac. – Chris Page Aug 19 '11 at 13:09
2

You can first try typing : export TERM=xterm If it did not work then you can try :

export TERM=linux

It works even in kernel with virgin system.