If we only had a pair of ruby slippers

Tonight was yet another in a long series of failed new architecture deploys at one of my clients. To those of us with experience in the field, this was no surprise. At two something in the morning, the CTO said “Why couldn’t tonight have been boring?”

Ever the person to tell the emperor that he is naked, I replied: “Well, when you push code that has never made it through a two hour live test into a production environment you have to expect it to blow up.”

Being the least experienced person in the room, the CTO replied: “That is just the pessimist in you.”

Damn… Gotta show the emperor a mirror… “No, that is the part of me that has run several development projects from beginning to end, and that used to lead a QA team. That’s the part of me that saying that.”

I don’t think he was looking at me as he actually said: “It doesn’t have to be that way.”

I give: “Last I heard the great and powerful wizard of oz was no longer on the throne.”

While it is true that coding can be an art, the steps used to test and verify code are in fact a science. You can build test cases. You can apply logic. You can reproduce results. It wouldn’t be Computer Science if you could just wish it didn’t have to be that way, and click your ruby slippers together chanting “this code will run” three times. Arthur C. Clarke said “Any sufficiently advanced technology is indistinguishable from magic”, and by that extension anyone who thinks they can wish code into running is not particularly advanced themselves…

-Chris

[ad#adsense-horizontal]

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]

Some tools work better than others.

A few years back I coded a website called HyperDictionary. It went through several life cycles of re-writes, moving from SQL database driven perl script to Dict client mod_perl module; bugt all the incarnations did basically the same thing: fetch dictionary definitions and then turn every word in the definition into a link to the definition for that word. I did it as an experiment while learning regex and mod_perl, but it ‘escaped’ into the wild thanks to web crawlers and became quite popular. The experiment ended when I needed to make a mortgage payment and I sold the site.

Not too long ago I was playing with the preg_ functions in PHP, and I decided to try to recreate the functionality of HyperDictionary with PHP. Now, I haven’t seen the HyperDictionary code in years, as deleting my local copies was part of the sales terms. I do remember the mod_perl module being fairly long and complex, even if I don’t remember how many lines of code it was. The trial version that I wacked together in PHP is essentially four lines of code. That’s a hell of an improvement over the original, though I am sure it will grow a little once I add search capability and word-of-the-day tracking. Still, the right tool can make a hell of a difference:

SubDomain Dictionary

-Chris

[ad#adsense-horizontal]

I use Amazon affiliate links in some of my posts. I think it is fair to say my writing is not influenced by the $0.40 I earned in 2022.