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:
But I got the following error:
xterm Xt error: Can't open display: :0.0
So 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.
From terminal.app I get:
xterm Xt error: Can't open display: :0.0
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 (~/).
Step 0. Check the value of the environmental variable “$Display”
- From a terminal window, issue the following command:
If the response is :0.0 (as you might expect), then perform the following steps
Step 1. Editing
- Check if
ls -a ~/.MacOSX/
If you get
ls: /Users/USERNAME/.MacOSX/: No such file or directory
The 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
- 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:
- And make it look like
- Save the
- Check that you don’t have any files called
.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
- 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_profile, and paste them at the end of
- You may want to check for and delete any duplicated lines in
~/.profileafter you paste them from the bash files.
- Save your new
- 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:
- You should get something random similar to
If 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:
- 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:
A funny app should now open in a new X11 window.