Saturday, December 1, 2007

X11 was lost, but now is found

For my lab work I use X11 all the time. I have to connect to school via ssh and run a custom program designed by CERN to analyze data from proton-proton collisions. When I installed Leopard the first time I didn't do an upgrade, after having read some disturbing issues with that. So I opted to use the migration assistant and install all my data from a smart disc image created by SuperDuper! That did work, and most things seemed to work after that, including X11. There were some problems, however, including more space taken up than I thought should be. So I reinstalled Leopard and manually brought my files and some programs over. It was a smart move on the behalf of disc space, I saved over 20 GB by doing this. That's how much unused junk I had on my system. Anyway, this didn't come without its costs though. X11 was barely functioning. Part of the problem is I didn't know what I was doing. I configured X11 for Tiger once, at the beginning of Summer, so I didn't remember a thing about what I read or how to do it.

Apple made several changes to X, including changing from Xfree86 to X.org or something like that. It turns out that if you keep your old .xinitrc and .bash_profile you will experience problems. X launches in a whole new way now. There are also two physical instances of X11.app on the system. I'm still confused by that, but now I don't care. You also should NOT run X at startup. One of the key features is that unlike Tiger, you can now click an X application and X will launch on it's own without having to be previously opened. That was a huge improvement. But it just didn't seem to work right. My connections would work for a little bit, then suddenly I'd get errors and nothing would work. No windows from the remote machine, and therefore no work done. I was getting rather upset by this because I wanted Leopard so bad, but didn't count on it breaking my connection to work.

This is when I decided to remove all instances of X11. I figured that somehow, some Tiger configuration got mixed in with Leopard and the whole thing was broken. Here are some steps I took to remove it. Type these commands in Terminal.

sudo mv /usr/X11 /tmp/
sudo rm /System/Library/LaunchAgents/org.x.X11.plist
sudo rm /Library/Receipts/X11User.pkg
sudo pkgutil --forget com.apple.pkg.X11User

Above instructions obtained from: http://aaroniba.net/articles/x11-leopard.html

I also added a few steps of my own which included a manual search for X11.app to ensure all copies got removed, those that didn't I deleted manually. Plus, I removed all instances of X11 preferences. I wanted no trace. Lastly, I knew that .xinitrc was a problem, so I renamed it and commented out the line in .bash_profile as follows:

#export DISPLAY=:"0.0"

Then, I reinstalled X11 from the optional installs folder on my Leopard disc. But before running it I restarted just to make sure everything was sound. (I know, this is proof that I was once solely a Windows user.) And still, before running X, I found this awesome update utility that would fix many of the current bugs. For some reason, Apple isn't releasing updates for X in a timely manner. They probably figure that they'll get it right first, but in the meantime we have to suffer. Fortunately, there are some bright people out there and X11 is being updated with many beta packages. To finally fix X, run these two commands from Terminal.app.

curl -LO http://people.freedesktop.org/~jeremyhu/x11-apple/x11_update.sh
sudo sh x11_update.sh

This was obtained from: http://www.x.org/wiki/XDarwin

What this will do is search for packages that need to be updated, download and install the updates. Ever since doing this, X has worked perfectly, it even shows up on my second monitor which was broken originally. Granted, these are not necessarily stable packages, but I trust these guys to get it right. If something doesn't work, you can bet they'll have a fix for it within a day and that's a damn sight better than Apple right now. I plan to run this script frequently and get myself on a mailing list so I know when updates are available. Thank you Jeremy, this has enriched my life!

[EDIT]
The above steps have been discontinued due to, I guess, different support of the Xquartz project. This link, http://forums.macosxhints.com/showthread.php?t=80171, tells you a bit about it and has links to the new source for X11 updates. It works just as well, if not better than Jeremy's solution, but his no longer works. These updates have been quite regular and have allowed my system to become more and more stable. Now, GIMP rarely crashes X11, and I can only imagine it will get better.


Apple Feedback

No comments:

Post a Comment