The Terrible Tale of iTunes 2

A tweet from Mr. Macintosh over the weekend reminded me of one of the worst bugs Apple shipped in an application update.

iTunes 2 warning

Version 2 of iTunes was going to be a big deal, including support for the just-announced iPod and the addition of an equalizer with cross-fading.

Things did not go well. Here’s a bit from Adam Engst, dated November 12, 2001:

After releasing the new version late Friday night, Apple hastily pulled the Mac OS X installer Saturday morning due to a problem where, in some situations involving multiple volumes named in specific ways, the installer could delete a large number of files. Needless to say, this is a bad thing, and there have been reports of Apple quietly offering to buy file recovery software or even pay for DriveSavers recovery of affected hard disks. A revised installer, with the designation iTunes 2.0.1, was released before the end of the weekend.

Apple put up a support page just about the issue:

Apple has identified an installer issue with iTunes 2.0 for Mac OS X that affects a limited number of systems running Mac OS X with multiple volumes (drives or partitions) mounted. For those systems, running the iTunes 2.0 installer can result in loss of user data.

While this error is highly unlikely to affect most users, Apple strongly advises that anyone who has downloaded the 2.0 version of iTunes for Mac OS X, as well as anyone who has a beta version of iTunes 2.0 for Mac OS X, immediately remove the iTunes.pkg installer file from their system.

The reason this issue happened is pretty interesting. Here’s Engst again:

The specifics of how this happened have been discussed at length in TidBITS Talk and similar forums, but roughly speaking, the installer Apple used to install iTunes in Mac OS X apparently relied on a shell script that assumed the previous version of iTunes would be in the Applications folder. Since everyone’s disks have different names, the script figured out the name of the disk, appended the path to the iTunes application, and then deleted all the files in the iTunes folder. Unfortunately, the script didn’t take into account the fact that people might put spaces in their disk names, particularly that they could put spaces at the beginning of the disk name. Since the space separates arguments in Unix commands, a command that would delete a single file is suddenly broken in the middle, transforming it into a command that can delete an entire disk. The problem can be avoided in Unix merely by enclosing the command in quotes, but that didn’t happen initially.

I wasn’t using OS X very much in the fall of 2001, but even six years later when I became a Mac Genius, I heard horror stories about this. Just check out this blog post from the time for a look at some of the carnage.