OS X != unix, and don’t you forget it…

I love my OS X laptop, don’t get me wrong. I run OS X Leopard as my primary OS, but I use parallels and Windows XP for some of those annoying Windows tools I need for my job (MS SQL Enterprise Manager, for example). I also love that I can compile and install just about any unix package that I would regularly use as a sysadmin. A decent OS X laptop is enough to spoil anyone.

Still, there are the little annoyances that bite you when you get too comfortable and complacent. For example… A few weeks back I tried to install the Pari math library using Darwin Ports. The build failed on a dependency, with the following output:

[h4606edac:ports/math/pari] root# port install pari
Portfile changed since last build; discarding previous state.
—> Fetching fontconfig
—> Attempting to fetch fontconfig-2.5.0.tar.gz from http://fontconfig.org/release/
—> Verifying checksum(s) for fontconfig
—> Extracting fontconfig
—> Configuring fontconfig
—> Building fontconfig with target all
Error: Target org.macports.build returned: shell command ” cd “/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_graphics_fontconfig/work/fontconfig-2.5.0″ && make all ” returned error 2
Command output: fcaliastail.h:520:2: error: #endif without #if
fcaliastail.h:522: error: only weak aliases are supported in this configuration
fcaliastail.h:523:2: error: #endif without #if
fcaliastail.h:525: error: only weak aliases are supported in this configuration
fcaliastail.h:526:2: error: #endif without #if
fcaliastail.h:528: error: only weak aliases are supported in this configuration
fcaliastail.h:529:2: error: #endif without #if
fcaliastail.h:531: error: only weak aliases are supported in this configuration
fcaliastail.h:532:2: error: #endif without #if
fcaliastail.h:534: error: only weak aliases are supported in this configuration
fcaliastail.h:535:2: error: #endif without #if
fcaliastail.h:537: error: only weak aliases are supported in this configuration
fcaliastail.h:538:2: error: #endif without #if
fcaliastail.h:540: error: only weak aliases are supported in this configuration
fcaliastail.h:541:2: error: #endif without #if
fcaliastail.h:543: error: only weak aliases are supported in this configuration
fcaliastail.h:544:2: error: #endif without #if
fcaliastail.h:546: error: only weak aliases are supported in this configuration
fcaliastail.h:547:2: error: #endif without #if
fcaliastail.h:549: error: only weak aliases are supported in this configuration
fcaliastail.h:550:2: error: #endif without #if
fcaliastail.h:552: error: only weak aliases are supported in this configuration
fcaliastail.h:553:2: error: #endif without #if
fcaliastail.h:555: error: only weak aliases are supported in this configuration
fcaliastail.h:556:2: error: #endif without #if
fcaliastail.h:557:2: error: #endif without #if
make[3]: *** [fcatomic.lo] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Error: The following dependencies failed to build: teTeX ghostscript fontconfig gsed texi2html texinfo
Error: Status 1 encountered during processing.

It was late, I was tired, and ports are frequently broken; so I figured I would come back to it later. Tonight I had time, so I updated my ports collection and tried again. Same error. Bugger…

Darwin Ports hides 99% of the build output from you, so I cleaned the ports and tried again with teh -v option:

port clean pari
port clean fontconfig
port -v install pari

As I watched the output something pretty obvious caught my eye. Pages and pages of the same text scrolled by:

Unknown option: 1
Usage: head [-options]
-m use method for the request (default is ‘HEAD’)
-f make request even if head believes method is illegal
-b Use the specified URL as base
-t Set timeout value
-i

send this HTTP header (you can specify several)

-u Display method and URL before any response
-U Display request headers (implies -u)
-s Display response status code
-S Display response status chain
-e Display response headers
-d Do not display content
-o Process HTML content in various ways

-v Show program version
-h Print this message

-x Extra debugging output

This is not just any error output, this is the output of the Perl LWP library’s HEAD command that is an optional install when you install the LWP library. There is no reason at all that this Darwin Port build of fontconfig should be invoking HEAD, but there are lots of reasons it would be invoking the unix command ‘head’. You see, the default OS X file system, HFS+, defaults to being a case-insensitive file system. HEAD is the same as head is the same as Head; and this is NOT the way a traditional unix file system works. It’s one of those subtle differences many OS X users don’t know that will bite them in the arse if they try to treat OS X like it is 100% unix under the covers.

I renamed HEAD to LWP-HEAD and everything is installing correctly now.

mv /opt/local/bin/HEAD /opt/local/bin/LWP-HEAD

If you found this page because you had the same problem and were looking for a solution, please add a comment and let me know if this worked for you.

-Chris

[ad#adsense-horizontal]

12 Replies to “OS X != unix, and don’t you forget it…”

  1. How did you install LWP? All the recent versions in the last few years default to naming the scripts lwp-* for exactly this reason.

    Case insensitivity is just the tip of the iceberg. Always remember: the _userland_ is FreeBSD, mostly. But the kernel is most decidedly not!

    Friends don’t let friends do Mach. 😉

    Paul

  2. Oh, I installed it by hand, via perl -MCPAN -e shell; and I most certainly chose to install the GET and HEAD aliases. The problem was absolutely my fault. When looking for a solution via Google I found a lot of other people who posted about the same problem but nobody posted a solution. So, despite it being an admission of my own mistake, I posted in the hopes of helping someone else past it. 🙂

    As for ‘Friends don’t let friends do Mach’… You are forgetting the Mantra! “All operating systems suck, they just suck in different ways.”

    -Chris

  3. “You see, OS X is a case-insensitive file system.”

    well first, os x isn’t a file system… HFS(+) is the file system and it can be either case-sensitive or case-insensitive. apple just defaults to creating partitions that are case-insensitive. so, you can always just create a case-sensitive partition and install on that.

  4. You are correct, I left out that detail while I was typing up the posting just before bedtime. I have updated the original post to reflect the situation more accurately.

    I have tried installing OS X onto a case sensitive filesystem. I had numerous problems and wound up reformatting rather than dealing with it. Mind you, that was back on an early Tiger release, and maybe Leopard manages it better; but I really don’t have the time to give it a try these days.

    -Chris

  5. I’m starting to hate OSX I can never get anything to work right on it. Todays hot list of problems are…

    1) mysql socket error
    2) htaccess upload problems
    3) mac ports problems
    4) xcode tools not installing
    5) imagemagick will not install, I get this crap!!!!

    mail:/opt/local/bin root# ./port install ImageMagick
    —> Building fontconfig with target all
    Error: Target org.macports.build returned: shell command ” cd “/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_graphics_fontconfig/work/fontconfig-2.5.0″ && make all ” returned error 2
    Command output: fcaliastail.h:520:2: error: #endif without #if
    fcaliastail.h:522: error: only weak aliases are supported in this configuration
    fcaliastail.h:523:2: error: #endif without #if
    fcaliastail.h:525: error: only weak aliases are supported in this configuration
    fcaliastail.h:526:2: error: #endif without #if
    fcaliastail.h:528: error: only weak aliases are supported in this configuration
    fcaliastail.h:529:2: error: #endif without #if
    fcaliastail.h:531: error: only weak aliases are supported in this configuration
    fcaliastail.h:532:2: error: #endif without #if
    fcaliastail.h:534: error: only weak aliases are supported in this configuration
    fcaliastail.h:535:2: error: #endif without #if
    fcaliastail.h:537: error: only weak aliases are supported in this configuration
    fcaliastail.h:538:2: error: #endif without #if
    fcaliastail.h:540: error: only weak aliases are supported in this configuration
    fcaliastail.h:541:2: error: #endif without #if
    fcaliastail.h:543: error: only weak aliases are supported in this configuration
    fcaliastail.h:544:2: error: #endif without #if
    fcaliastail.h:546: error: only weak aliases are supported in this configuration
    fcaliastail.h:547:2: error: #endif without #if
    fcaliastail.h:549: error: only weak aliases are supported in this configuration
    fcaliastail.h:550:2: error: #endif without #if
    fcaliastail.h:552: error: only weak aliases are supported in this configuration
    fcaliastail.h:553:2: error: #endif without #if
    fcaliastail.h:555: error: only weak aliases are supported in this configuration
    fcaliastail.h:556:2: error: #endif without #if
    fcaliastail.h:557:2: error: #endif without #if
    make[3]: *** [fcatomic.lo] Error 1
    make[2]: *** [all] Error 2
    make[1]: *** [all-recursive] Error 1
    make: *** [all] Error 2

    Error: The following dependencies failed to build: fontconfig jpeg libpng libxml2 pkgconfig tiff
    Error: Status 1 encountered during processing.

  6. Raul,

    #1 You didn’t mention what is giving you a mysql socket error, whether it is the mysql command line util, or PHP, or what… But I will bet this is because the software that gave the error is looking for mysql.sock in a different place than it is installed. Find where mysql.sock is located on your system, find where your software expects it, and set up a symlink. (I had this problem the first time I set up PHP on my Tiger box.)

    #2 “htaccess upload problems” I have no idea what you are talking about.

    #3 If you can’t install xcode, then #4 and #5 are a given.

    #5 This is the _exact_ same error I talked about in this post. You will notice that while you were trying to compile ImageMagick, the actual error is on the dependency of fontconfig. Try one of these two things:

    #1 This will locate any other commands on your system named ‘head’, no matter what case. This will help if the problem is the exact same one I had:
    locate head | egrep -i “/head$”

    #2 Invoke the install command with -v so that you get verbose output, and then read ALL the output looking for the source of the problem:
    ./port -v install ImageMagick

    -Chris

  7. very useful – thanks.

    My perl ‘HEAD’ had already overwritten my unix ‘head’ … crazy … your post got me on the right track to realizing this was what was going on. I had to copy my ‘head’ back from the install DVD (or I could have compiled it from the Darwin source) to get it back … (my backups already had a ‘HEAD’ without my knowledge!)

    I also enjoy OS X as a primary OS but occasionally run into something (like this!) that is just mind-numbingly stupid design! (whether it be the OS or its default FS type)

    Cheers!

  8. Thank you very much for this post. I was unable to install the gimp.app because it was getting fouled up on the fontconfig install. I found that my HEAD file was in /usr/bin using the command:

    #> which head

    I found that the file was a text file and not the original OS X file by doing the command:

    #> file /usr/bin/head

    I replaced the file and tried to the install again, only to have it fail AGAIN!!. The last poster is absolutely correct. Do the “clean”ing of the port first.

    #> port clean fontconfig

    After that it installed completely without and error. I never would have caught this problem with the HEAD file. Not even on my train of thought until I found this post.

    Once again, Thank you very much.

  9. Chris,

    Thank you very much for the explanation! I had this very problem when trying to install TexLive. I found your page when I Googled the error: ‘Target org.macports.build returned: shell command ” cd “/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_graphics_fontconfig/work/fontconfig-2.5.0″ && make all ” returned error 2’

    Like ozziem, my *nix head command had been overwritten(!) with LWP’s HEAD. Following all the good advice above, here are the steps I had to do on my Macbook (Tiger) in order to get rid of the compilation error:

    1. sudo mv /usr/bin/HEAD /usr/bin/lwp-HEAD
    2. Insert Mac OS Install Disk 1 and copy /Volumes/Mac OS X Install Disc 1/usr/bin/head from the install disk to /usr/bin/ on the hard drive.
    3. sudo port clean all (though I guess ‘sudo port clean texlive’ would have worked)

    After that I was able to install like a champ!

    Thanks again for posting the solution to this problem, which I doubt I would have ever solved on my own.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.