UPDATE 3 - Better Solution

I kept Google'ing this until I came to a different solution. I ended up downloading the terminfo directory from somewhere (I forgot where so I just posted the zip on my website here) and replaced my current working terminfo directory with the new stuff.

The terminfo directory, for me, is located at...



bahamat helped me get to the solution. I added the following to my .profile...

export TERM

... and I am still able to keep "xterm-256color".


I figured out why this is happening. At one point, I changed some settings...

enter image description here

The default is "xterm-color" and I changed it to "xterm-256color". Is there a reason for this to be happening?

I just set up a second admin user account on a fresh install of Mac OS X Lion and now when I try to clear the terminal, I get the following error...

Hristo $ clear
terminals database is inaccessible

This is a problem for both user accounts and I have no idea why. I'm not sure if this is much help, but here is what $TERM is set to...

Hristo $ echo $TERM

Any thoughts as to why this might be happening?

Let me know if I need to show my .bashrc or .profile.


Looks like your TERM value isn't recognized. You are probably setting the TERM value in your .profile (or similar) or you've got missing/corrupt files or invalid permissions in /usr/share/terminfo/.

  • hmm... I am not setting the TERM value in neither account's .profile and the permissions are 755 for all directories under /usr/share/terminfo/ with owners root wheel – Hristo Aug 6 '11 at 22:41
  • Run echo $TERM and tell me what it says. – bahamat Aug 6 '11 at 22:57
  • @bahamat... that is in my post above. it says "xterm-256color" – Hristo Aug 6 '11 at 22:58
  • Sorry, don't know why I missed that. Look at /usr/share/terminfo/78/xterm-256color. Does it exist? Is it readable by you? Try changing your TERM to xterm and see if the problem persists. – bahamat Aug 6 '11 at 23:03
  • xterm-256color does not exist and how would I change TERM to xterm? – Hristo Aug 6 '11 at 23:15

In Mac OS X Lion 1.07, Terminal now supports 256 colors, Background Color Erase (BCE) and some other features that make it more compatible with modern xterm, and the default value for $TERM is now xterm-256color instead of xterm-color (which represents an older branch of xterm with less functionality).

If you upgrade to Lion, any settings profiles that used xterm-color will use the new default. (All "Declare terminal as" does is set the value of $TERM, by the way.)

The error you're seeing indicates that the appropriate terminfo files for xterm-256color are either missing or inaccessible. You might try installing Lion again. Also, some people have reported that installing Xcode 4 on Lion can cause this problem.

You can test the validity of xterm-256color with the following shell command:

infocmp xterm-256color

This will either display an error or the appropriate terminfo values for xterm-256color, and, if found, it displays the pathname to the terminfo file it used.

  • running $ infocmp xterm-256color results in infocmp: couldn't open terminfo file (null). So I'm assuming something is wrong. I did install Xcode 4 but can't definitively say that it was the reason. Any suggestions? I would prefer not to reinstall Lion... – Hristo Aug 11 '11 at 7:44
  • ... seems to work now... no idea what changed – Hristo Aug 11 '11 at 7:48
  • I'm missing the profile for xterm-256color under /usr/share/terminfo/78 as well. For now setting the default terminal back to xterm-color. – Ari Braginsky Oct 7 '11 at 19:06
  • Using xterm-color is not recommended, as it describes an older, less capable branch of Xterm. If xterm-256color isn't installed, the next best $TERM values to try are xterm-88color, xterm-16color and xterm, in that order. – Chris Page Oct 10 '11 at 8:36
  • Terminal's "Declare terminal as" preference setting only contains xterm, xterm-color and xterm-256color. However, you can set it to other values by editing preferences with defaults write com.apple.Terminal … or by editing the com.apple.Terminal.plist preferences file. Or, you can change the value of TERM in your shell startup file, e.g., put export TERM=xterm-88color in ~/.bashrc (and if you haven't already done this, create a ~/.bash_profile that runs ~/.bashrc). – Chris Page Oct 10 '11 at 8:50

xterm-256color should be present in /usr/share/terminfo/78.

Run this command and double check if it's there:

ls -laR /usr/share/terminfo

In the past, there were issues with Xcode messing up permissions to a huge degree. Worst case scenario, use disk utility and repair your permissions. You will need to boot from an install DVD and verify/repair your boot partition.


Super easy to fix...

Create a symbolic link so the computer sees xterm-color as xterm-256color:


ln -s /usr/share/terminfo/78/xterm-color /usr/share/terminfo/78/xterm-colorxterm-256color


I also came across this error on the new Mac. In my case, the error is caused by using "conda create -c rdkit -n rdkit-env rdkit" (source link) to create a conda environment with the rdkit for Python3.7 on Mac. Otherwise, the clear command works fine for the other conda or virtual Python environments.

Adding the following line to ~/.bash_profile or ~/.bashrc solves the issue for me (source link):

export TERMINFO=/usr/share/terminfo

N.B.: I did not try @Christopher Brunner's symbolic link solution which requires sudo, but sudo command is not always available for someone who works with university computer or HPC computers.

In addition, for those who also have the issue about "cannot repeat last command in python interpreter shell" or "Seeing escape characters when pressing the arrow keys in python shell", as follows:

>>> import numpy as np, pandas as pd
import rdkit, pubchempy>>> 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pubchempy'
>>> ^D

A general solution is you would need to install py-readline or deadline package for python.

conda install readline # for conda environment for Python
pip3 install deadline

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.