Fix xterm launch from Terminal.app in Mac OS X 10.5 (display error solved!)
Ok, so recently I started playing with ported apps on Leopard using Fink and Macports. Specifically, I installed the ARB Package as indicated in http://greengenes.lbl.gov/mlds/.
In one of the steps of the painful procedure it is suggested that launching xterm from the Terminal.app should be enabled, so this is how I came across this techie challenge. After upgrading to the latest version of X11 from Quartz, and after installing Mac’s Xcode tools. I proceeded to launch the X11 Terminal window from the Terminal.app command line, by issuing the following command:
xtermBut I got the following error:
xterm Xt error: Can't open display: :0.0So I did some frustrating research throughout the web, and found that there are tons of posts and forums entries about it, but none of them seemed to work for my case. So I combined a couple of ideas from different posts, to finally find out that the solution is quite simple.
The Error
When issuing
xtermFrom terminal.app I get:
xterm Xt error: Can't open display: :0.0The Solution
Comment out or delete any explicit declaration of the environment variable $DISPLAY in any of the environment variable files (i.e.: ~/.profile, ~/.bash_profile, ~/.bash_login or ~/.MacOSX/environment.plist), to allow the system set this variable automatically.
- Enable viewing hidden files in finder: To perform the following steps quickly, you should enable viewing hidden files in Finder.app. This can be done using the procedure described here, or using a Mac OS X maintenance app such as IceClean. By default Finder.app does not show hidden files, these files or folders have dot (.) at the beginning of their names.
- The Home Folder: In this post when I make reference to a file as ~/FILENAME, I am indicating that FILENAME is in your Home folder (~/).
The Procedure
Step 0. Check the value of the environmental variable “$Display”
- From a terminal window, issue the following command:
echo $DISPLAY
If the response is :0.0 (as you might expect), then perform the following steps
Step 1. Editing environment.plist
- Check if
~/.MacOSX/environment.plistexists:ls -a ~/.MacOSX/If you get
ls: /Users/USERNAME/.MacOSX/: No such file or directoryThe file doesn’t exist and you may proceed to Step 2 below. If in the command output you see a file named “environment.plist”, then (remember that you must enable viewing hidden files in finder):
- Open Finder, go to your home folder (where you can find the Documents, Pictures, Music and other folders)
- Search for the folder named .MacOSX/
- Open it and open the file environment.plist
- Delete the entry with the variable
$DISPLAY
- You may find more information about this procedure here
Step 2. Editing the shell environment files
- Open Finder.app and go to your home folder
- Open the
.profilefile in your favorite text editor. Or from the command line in Terminal.app do:sudo pico ~/.profile - In the file
~/.profilelocate the line that looks like:export DISPLAY=:0.0 - And make it look like
#export DISPLAY=:0.0 - Save the
~/.profilefile - Check that you don’t have any files called
.bash_profileor.bash_loginin your home folder (~/). You can check this from the Terminal.app by issuing:ls -a ~ - If you don’t see the “
.bash_” files, proceed to Step 3. If you do, continue below.
For the sake of simplicity, in the macports documentation, it is recommended to have only one file to declare environment variables, so the following procedure as recommended in http://guide.macports.org/#installing.shell, allows you to declare all your environment variables in your ~/.profile file:
- Backup your .profile, .bash_profile and .bash_login files:
cp .profile .profile_bkp
cp .bash_profile .bash_profile_bkp
cp .bash_login .bash_login_bkp
- Using your favorite text editor, copy all the contents of your
~/.bash_loginand~/.bash_profile, and paste them at the end of~/.profilefile. - You may want to check for and delete any duplicated lines in
~/.profileafter you paste them from the bash files. - Save your new
~/.profilefile - Delete the bash files by doing:
sudo rm ~/.bash_login
sudo rm ~/.bash_profile
This step will force ~/.profile to be the only custom environment variable file loaded when opening a terminal
Step 3. Checking that everything works fine
- Restart your Terminal.app and check out the new value of $Display by doing:
echo $DISPLAY
- You should get something random similar to
/tmp/launch-bmD1Hb/:0If you get something similar to this, it means that your system set the $Display environment variable automatically, and that you are on your way to happiness.
- Check that the X11.app is not open, restart your Terminal.app and issue the xterm command from the Terminal.app window:
xterm
- If the above step launched the X11 terminal properly, you may even be able to open X11 apps from the Terminal.app window. To check this, close the X11.app and issue the following command from the Terminal.app command line:
xeyes
A funny app should now open in a new X11 window.

Mac x11 terminal dosen’t start.? when i click it suddenly come and gone. (like a flash)
this error msg. came tru terminal
Last login: Sun May 17 04:56:41 on ttys000
dyld: lazy symbol binding failed: Symbol not found: _tgetent
Referenced from: /bin/bash
Expected in: flat namespace
dyld: Symbol not found: _tgetent
Referenced from: /bin/bash
Expected in: flat namespace
[Process completed]
what is this. please help.
I have mac book pro (os x 10.5.7 Leapord)
Did this start to happen after you followed the above procedure?
no. i installed bash. after that this msg. came. is it a big error. the only prob. is terminal starting. text wrangle, gimp, inkspace working well. thanks
Take a look at your ~/.bash_login or ~/.bash_profile with a text editor, maybe you can find some lines that are related to the problem. If you do find something related, comment those lines. Then try to launch your X11 again and see what happens…