I actually ran into this problem after upgrading to Mountain Lion )(I think Lion has the same issue) and trying to run xterm on remote machine using ssh tunneling. No matter what I did the command always failed with
Warning: This program is an suid-root program or is being run by the root user.
The full text of the error or warning message cannot be safely formatted
in this environment. You may get a more descriptive message by running the
program as a non-root user or by removing the suid bit on the executable.
xterm Xt error: Can't open display: %s
xterm: DISPLAY is not set
(Well the “Can’t open display %s” only appeared because I did a terrible thing: ssh as root, anyway …)
I even installed xserver with macports, but that also didn’t help. So here is the solution …
MacOS keeps the X11 programs in “/usr/X11/bin”. If you “cd /usr/X11/bin” you will actually see those programs, but once you try to run any of them (for instance oclock) you will get error dialog saying:
X11 is no longer included with OS X
Hah! Well, that’s bad news, but some good news will come on the page that will appear after you click “Continue”. This will lead you to the XQuartz opensource X Server for OS X: http://xquartz.macosforge.org/landing/. On the landing page you will find the download link. Install that package and it will enable you to run X11 apps (including remotely via X11 forwarding in ssh). Oh, logout/login is required after the installation.