If you find these following errors in MacOSX terminals, then the reason might be a corrupted “terminfo” directory. These issues affect all types of terminal such as iterm2, oh-my-zsh etc. Luckily the fix is pretty simple.
- Error opening terminal: xterm-256color.
- tput: unknown terminal “unknown”
- zsh: can’t find terminal definition for xterm
- E558: Terminal entry not found in terminfo
Modify the permission of “terminfo” folder.
sudo chmod 655 /usr/share/terminfo
sudo chmod +rw /usr/share/terminfo
This should fix the issues. If the issue still persists, then look at the following solution.
1. Download OSX Installer from the App Store.
2. Open OSX installer in Finder (Right click -> Show Package Contents)
3. Open InstallESD.dmg (under “SharedSupport”)
4. Unpack BSD.pkg (under “Packages”). You can use “unpkg” application for this.
Terminfo can be found inside the new BSD folder in /usr/share/terminfo
You need to replace the ‘terminfo’ folder on your system with this new one. If you don’t want to download the whole OSX installer package, then you can always get the ‘terminfo’ folder from another OSX system.