A blog by Gary Bernhardt, Creator & Destroyer of Software

Undeletable zombie files on OS X

13 Sep 2007

Somehow, one of BitBacker's system tests occasionally creates an undeletable file. It happens within a test that generates random filenames, then tries to back up and restore them. Unfortunately, there are apparently some character sequences that make HFS+ choke. I've only had this happen twice ever – once on my 17" MacBook Pro, and just now on my brand new 15" MacBook Pro. Here's what the file looks like:

A broken file

It can't be deleted from Finder:

Trying to delete a broken file from Finder

It can't be deleted from the console:

Trying to delete a broken file from the console

And it can't even be "ls"ed:

Trying to ls a broken file

If I manually move the containing folder to the trash and try to empty it, I get this, which is even more ridiculous than the rest:

Trying to delete a broken file from the trash

I've googled for undeletable files on OS X, as well as for the specific error messages Finder throws, and tried every suggested fix I found. And, of course, I've tried to delete the file from within Python:

>>> os.unlink(os.listdir('.')[0])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  OSError: [Errno 2] No such file or directory:

Dear Apple: please replace HFS+. Seriously, it sucks.