Mac OS X 10.5: Spotlight searches no longer broken in Mail

Posted by Pierre Igot in: Macintosh, Mail
March 16th, 2008 • 10:36 am

Since I wrote this post about broken Spotlight searches in Mac OS X 10.5’s Mail application, there have been some interesting developments.

As per usual, at the same time I wrote the post, I submitted a detailed bug report to Apple via Bug Reporter. The bug report was specifically about the fact that Mail was no longer automatically indexing new messages that I was receiving in Mail. (I kept the fact that Spotlight searches focused on a specific mailbox were not working either for a separate bug report.)

I indicated that Spotlight searches on entire messages in all mailboxes worked, but only to find messages that had been indexed during the last manual repair steps that I had described in the post above. Newer messages were not being indexed automatically.

A while later, I received a message from Apple’s engineers asking to provide them with the output of several sequences of Terminal commands, which, as far as I could tell, were supposed to show them how well automatic Spotlight indexing was working on the volume where my Mail folder is stored.

They also asked the following two questions:

2 – Have you ever installed a 3rd party App which acts as a Mail program or tries to “enhance” mail?

3 – Do you have any attached partitions with older versions of Mac OS, specifically Tiger or Panther?

My answer to #2 was that, yes, I had installed both the Mail Act-On and MailTags “bundles” that provide enhancements in Mail. I had kept Mail Act-On (which I am still using), but removed MailTags, which was of limited interest to me.

But I had noticed later on that, even after removing MailTags, there was still a MailTags-related .mdimporter file inside my mail library’s “Spotlight” folder, so I had manually removed that file as well.

But these steps had failed to fix the problem with automatic Spotlight indexing in Mail.

My answer to #3 was that, yes, indeed, I still had Mac OS X 10.4.11 installed on another partition, although I hadn’t used it in months. But I specified that my user’s Mail folder on that other partition was actually an old symbolic link to the same Mail folder I was using now in Mac OS X 10.5.

That said, it made me suspicious that having older versions of Mail installed somewhere on one’s volumes might be part of the problem. So I went to the “Spotlight” preference pane in System Preferences in Leopard, and add the entire volume containing that old Mac OS X 10.4.11 install to the “Privacy” tab, so that Spotlight would ignore it altogether.

Still, that did not fix the problem.

Apple got back to me again a few days later, with yet more Terminal commands to run, again apparently in an attempt to better identify Spotlight-related settings for the volume containing my Mail folder. I dutifully obliged and sent them the output. I haven’t heard from them since then.

But during that same period, I had another, apparently unrelated problem with Nolobe‘s Interarchy FTP application, which had started systematically crashing when launched in my regular user environment. I was still able to launch the application without problems in another user environment, but not in my own. I tried trashing all kinds of preference files, to no avail. I got in touch with Nolobe’s tech support about the problem, and they suggested trashing all the files and restarting the machine and reinstalling Interarchy altogether.

Since they insisted on my restarting the entire machine before reinstalling, arguing that “Mac OS X does a lot of caching” and that “a restart will hopefully flush any caches,” I figured I had nothing to lose by going one step further and doing a safe boot first.

A safe boot (booting Mac OS X with the Shift key down) not only prevents system extensions from loading, but it also clears some caches. The tech note about safe booting only mentions font caches, but I wouldn’t be surprised if it also clears some other, undocumented caches.

In any case, doing a safe boot first, and then a normal reboot, and reinstalling Interarchy did fix the problem with that application, and I was even able to reuse my existing pref files, which obviously were not part of the problem (so that I didn’t have to recreate all my Interarchy bookmarks as well).

What does all this Interarchy business have to do with broken Spotlight searches in Mail? Well, I don’t really know… But what I do know is that, yesterday, when I was using Mail and trying to use its Spotlight search tool to find a recent message, I was surprised to discover that Mail had indexed newer messages received since the last time I had run the manual repair steps to try and fix my Spotlight searches in Mail!

And indeed, since then, I have been able to confirm that, somehow, Mail has decided to work again when it comes to automatically indexing new messages. Not only that, but searches focused on a specific mailbox (as opposed to all mailboxes) are also working again!

How did this happen? I don’t really know. All I know is that I excluded the partition containing Mac OS X 10.4 and its Mail application from Spotlight indexing, and then for unrelated problems I recently did a safe boot.

Is that what fixed the problem? It is impossible for me to say. I suppose I could try to reverse the process by removing my Mac OS X 10.4 partition from the “Privacy” tab and rebooting my machine again, but somehow, I don’t really feel like it.

Still, I strongly suspect that the presence of this old Mail application on one of my partitions was a key factor, especially since Apple’s engineers themselves raised the issue (albeit indirectly) in one of their emails. It would seem that there is a bug in Mac OS X 10.5 that causes it to incorrectly refer to the older Mail application instead of the one on the startup volume for certain things, and that this bug causes the Spotlight searches in Mail and the automatic Spotlight indexing of new messages to cease to work properly.

It also seems to indicate that Apple is aware of the problem, so there is hope that a fix is in the works.

The one thing that I noticed is still not working properly in Mail’s search feature is that, if you search for a keyword that only appears in a message’s subject line and not in the body of the message, a search for the keyword in “Entire Messages” fails to return the message in the results. You have to focus the search on message subjects in order to get the message in the results.

But I believe that this is a long-standing problem in Mail and not something new. As we know, the searches on “From,” “To,” and “Subject” use a separate index (which is stored in the “Envelope Index” file inside the Mail folder), and I suspect that searches on “Entire Messages” fail to include that separate index and only search in message bodies. It is annoying, but at least it is a known problem and one that can relatively easily be worked around.

I should also mention that I have just received a long message from another Betalogue reader who had the exact same problems, and he too was somehow able to repair them, although through a different (and far more complex) sequence of steps, many of which he is not sure are really related to the fact that the problems are fixed on his machine.

But his key observation is that, on his machine too, the problem was “triggered by the presence of an older copy (v1.3.9) of Mail on an external bootable drive that was attached while I upgraded to Leopard.” And he too ended up removing the volume containing the older Mail from the equation (by disconnecting the drive in his case) and rebuilding stuff after that. He didn’t mention doing a safe boot, but he did rebuild launch services, using a command similar to the one described in my original post, albeit in a “slightly wider-ranging and angrier version” (his words):

sudo /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -R /

So maybe it is the combination of removing the older Mail from the equation and doing some kind of cache rebuilding that ultimately fixed the problem in both cases. It certainly looks to have been the case on my machine.

Here is hoping that all this information can be useful to others as well.

Comments are closed.

Leave a Reply

Comments are closed.