Thursday, November 16, 2006

God Damn I Hate Cygwin

First of all, let's get the rant out of the way. Cygwin is a big pile of junk. It's like everyone who touches Cygwin gets the clue beaten out of them before they're allowed to hack on it. Here's a tip guys, if you're going to try to do something really hard (like build a POSIX compatible software layer on top of an operating system that holds many parts of the POSIX standard as the anti-thesis of its design) you have to put a lot of effort into it. Ok, done.

I recently had this problem:
Fatal server error: could not open default font 'fixed'

for which I googled, lots and lots and lots and found no adequate solution. I found the Cygwin/X Frequently Asked Questions and it had two suggests as to what the problem could be:
  1. You don't actually have the xorg-x11-fnts package installed (duh, thanks guys, yeah, that wasn't the first thing I checked).
  2. The mount point for /usr/X11R6/lib/X11/fonts was invalid at the time that Cygwin's setup.exe installed the xorg-x11-fnts package.

This advice is, of course, absolutely useless. What mount point are you talking about guys? In what way could it be "invalid"? Why would have I have to manually fuck around with this stuff anyways? My /usr/X11R6/lib/X11/fonts happens to be mounted on /, which is mounted to c:\cygwin.. ya know, like everyone else who uses cygwin. What the hell are you guys on about?

Well, turns out what they are trying to say is that you need to make a mount point for /usr/X11R6/lib/X11/fonts. The problem is that stupid "do you want to use unix mode or text mode?" option at the start of the cygwin installer. Probably 50% of people choose unix mode, then discover something doesn't work (like, say, scripts that have been checked into a repository by someone who chose textmode) and then quickly change to textmode. If you are using textmode for /. then you will have this problem. Here's how to fix it:
foo@mymachine ~
$ cd /usr/X11R6/lib/X11
foo@mymachine /usr/X11R6/lib/X11
$ mv fonts fonts_real
foo@mymachine /usr/X11R6/lib/X11
$ mount -b c:\\cygwin\\usr\\X11R6\\lib\\X11\\fonts_real 
           /usr/X11R6/lib/X11/fonts

Your fonts dir should now be mounted in "binmode". But that's not all! You need to edit /usr/X11R6/bin/font-update and look for a need_update="", between those quotes, put a 1. Now do:
foo@mymachine ~
$ /usr/X11R6/bin/font-update

and don't forget to edit /usr/X11R6/bin/font-update and take the 1 out of those quotes.

If you are a Cygwin/X developer, please, please, please add a mount command to the installer! We shouldn't have to do this shit manually!

13 comments:

  1. THANK YOU!!!

    I had 3 days of searching for solution!

    (I did not do the 'mv' command, however)

    ReplyDelete
  2. Thanks a lot. I don't know why this font-update stuff isn't there anywhere else on the web - not even on the Cygwin FAQ

    ReplyDelete
  3. Beautiful work! - have you posted this to cygwin?

    ReplyDelete
  4. THANK YOU!!! I can't get over how difficult it is to use X in cygwin nowadays. Plus when people ask questions of the cygwin folks, they get all huffy and pissy and tell you to read the docs. People should just be coming directly to your helpful blog.

    ReplyDelete
  5. THANK YOU!!!

    and Cygwin FAQ sucks!

    ReplyDelete
  6. Nice, thanks. For some reason, my dir didn't even have a "fonts" folder, but once I added one, your steps worked perfectly.

    ReplyDelete
  7. Geez. I thought it was just me. Cheers!

    ReplyDelete
  8. Thanks heaps! I couldn't get the "remounting" to work so changed to binary mode and did the "font-update" thing. Now I have X again!

    (which means I can copy and paste into a shell window - why can't I do that without X anyway?)

    ReplyDelete
  9. Absolutly fanfuckintastic!

    Consider this page book-marked for all of my students to see a solution to this bloody problem!

    Big :-D to you!

    ReplyDelete
  10. Oddly enough, this did not fix the error on my cygwin install...


    C:\cygwin\usr\X11R6\lib\X11\fonts on /usr/X11R6/lib/X11/fonts type system (binmode)
    C:\cygwin\bin on /usr/bin type system (textmode)
    C:\cygwin\lib on /usr/lib type system (textmode)
    C:\cygwin on / type system (textmode)
    c: on /cygdrive/c type system (textmode,noumount)
    f: on /cygdrive/f type system (textmode,noumount)
    k: on /cygdrive/k type system (textmode,noumount)
    l: on /cygdrive/l type system (textmode,noumount)

    (WW) /tmp mounted int textmode
    _XSERVTransmkdir: Owner of /tmp/.X11-unix should be set to root
    (II) XF86Config is not supported
    (II) See http://x.cygwin.com/docs/faq/cygwin-x-faq.html for more information
    winAdjustVideoModeShadowGDI - Using Windows display depth of 32 bits per pixel
    winAllocateFBShadowGDI - Creating DIB with width: 1800 height: 1440 depth: 32
    winInitVisualsShadowGDI - Masks 00ff0000 0000ff00 000000ff BPRGB 8 d 24 bpp 32
    null screen fn ReparentWindow
    null screen fn RestackWindow
    InitQueue - Calling pthread_mutex_init
    InitQueue - pthread_mutex_init returned
    InitQueue - Calling pthread_cond_init
    InitQueue - pthread_cond_init returned
    winInitMultiWindowWM - Hello
    winMultiWindowXMsgProc - Hello
    winInitMultiWindowWM - Calling pthread_mutex_lock ()
    winMultiWindowXMsgProc - Calling pthread_mutex_lock ()
    MIT-SHM extension disabled due to lack of kernel support
    XFree86-Bigfont extension local-client optimization disabled due to lack of shared memory support in the kernel
    (--) Setting autorepeat to delay=500, rate=31
    (--) winConfigKeyboard - Layout: "00000409" (00000409)
    (--) Using preset keyboard for "English (USA)" (409), type "4"
    (--) 8 mouse buttons found
    Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!

    Fatal server error:
    could not open default font 'fixed'
    winDeinitMultiWindowWM - Noting shutdown in progress


    Quest for a solution continues..

    ReplyDelete
  11. *smaks forehead*

    Dont forget to do the old

    cd /usr/x11r6/lib/x11/fonts
    mkfontdir *

    ... after all that, otherwise the line-enders are still wrong for how Xwin reads the files in Binmode... Duh.

    ReplyDelete
  12. THANK YOU AGAIN!!!!

    I've spent hours trying to fix this/find out what's wrong. Finally encountered your blog, followed your instructions, and it's all fine now. Incredible - two years since your post and the Cygwin install is still as broken as ever!

    ReplyDelete
  13. There is quite a significant reason to ditch Cygwin and install Cooperative Linux - does the same job, but natively and therefore much faster.

    Want X? There are plenty of free X clients out there.

    ReplyDelete