The Case of the Unexpected Pax

It was late afternoon of a chill November in Paris. I was walking along the quai, lost in a brown study. Looking up, I saw my friend C. Auguste Dupin approaching me.

"Ah, bon soir, mon ami," said Dupin, "and what brings you beside the Seine on this crisp evening?"

"Something has been puzzling me," I replied, "and I thought the walk would give my thoughts an opportunity to put themselves in order."

"It is a day of puzzlements, no? Will you not share your puzzlement with me?"

"Well," I demurred, "it is a small thing -- probably something I did to myself. But I do not wish to intrude on your time."

"Ah, but it is no intrusion for a friend."

"Well," I said as we turned across the Pont Neuf, "as you know I dabble in Perl, and I like to keep a variety of systems available for testing purposes. I upgraded one of these and was re-installing Perl, when one single module failed to install -- indeed, failed to unpack."

"Perhaps the author had the misfortune to make a bad package."

"No, I don't think so. The same package unpacked and installed correctly on other systems. I suspected something OS-specific, but Perl Testers reports no such problems with the package. Then I suspected my cpan client, but I deleted everything from the .cpan directory but the configuration, to no avail."

"Most unusual. You say this distribution failed to unpack. Can you be specific?"

"Yes," I replied as we turned onto the Quai de Conti, "it was odd. When I used the cpan look command, I found myself in a directory named after the author of the package. That directory contained the actual package in a subdirectory, along with some other stuff."

"In a subdirectory you say? Was it a good copy?"

"Yes. I was able to install from it by hand, the only problem being that there was a dependency to take care of."

"And this so-called 'other stuff'," Dupin pursued, "of what did it consist?"

"It was a directory -- PaxHeaders.11295 or some such. I did not look into it."

"Ah, that is very interesting. Tell me also under what operating system did you experience this problem?"

"OpenBSD. I had no problems under FreeBSD or Linux."

"Yes, that follows. But to complete the picture we need one final piece. Tell me, mon ami, how have you set up cpan to unpack your distributions?"

"I don't know. The default I suppose, whatever that is. Does it make a difference?"

"It does indeed, mon ami," Dupin replied. The cpan client uses setting prefer_external_tar to determine whether it uses an external executable or Perl modules to unpack the distribution. Unless you explicitly set this, it tends to be 1, which uses an external tar, or undef, which leaves it to discretion of the CPAN::Tarzip code.

"I still don't see the point," I exclaimed, "tar is tar, is it not?"

"By no means!" Dupin asserted. "This pax that gives you no peace was an archiver introduced to try to unify tar and cpio. It never really caught on, but the format was enshrined in a POSIX standard, and some tar programs add pax metadata in response to --format=posix. Linux uses Gnu tar, which understands this sort of thing. FreeBSD use bsdtar, which can also cope with the pax metadata. OpenBSD, however, does not."

"So I have to replace the system tar with Gnu tar?"

"Indeed, that is what CPAN::Tarzip suggests. But on a new installation such as yours, or any installation with a modern Archive::Tar, it suffices to set prefer_external_tar to 0."

"Just that? I am tempted to misquote the Bard of Avon: 'The fault, dear Brutus, is not in our selves but in our tar.'"

With apologies to Shakespeare as well as Poe.

This was a problem I ran into recently. With no Dupin to guide me I went to even greater lengths than Dupin's anonymous friend to try to sort the problem out. Eventually I convinced myself that the system tar itself gave rise to the extra file, which confused CPAN::Tarzip mightily. Yes, I could have painstakingly characterized the various tar programs involved, but it was much easier to turn off prefer_external_tar and see if that fixed the problem. It did, and the rest was, well, not so much history as a blog entry inflicted on long-suffering readers.

The couple of sentences on the origins of pax are derived (perhaps faultily) from the relevant Wikipedia article.


Its funny that you should post one of these cases today. I was thinking about doing one myself (featuring the detective I am more familiar with) and now seeing this I feel I must. :-)

As perhaps you have noticed, I did post my story. I worried a little about using Holmes, but more for the implication of putting myself in Holmes’ shoes. In the end I went with it because I understand the tone and voice of Doyle’s famous detective narratives.

Leave a comment

About Tom Wyant

user-pic I blog about Perl.