5

Issue

After forcing Spotlight to reindex, no files or directories can be found.

Setup

I've got a MacBook Pro 15" 2017 with a 512 GB SSD: 250 GB main volume (36 free) and a BOOTCAMP partition (not indexed), running macOS High Sierra (10.13.6). The file system is APFS.

How it happened

I wanted to force a Spotlight re-indexing (because a file, that was definitely in place, was missing in Search), so I added the whole volume to System Preferences -> Spotlight -> Privacy, and then removed it from there (Apple Support link), which should've caused a full Spotlight reindex. It did. a bunch of mdworker processes appeared and started consuming CPU time and reading stuff from disk (which is expected).

Then they stopped. They are still there but they don't seem to be doing anything judging by the CPU load / disk usage stats.

And yet, now I can't find ANY files. Spotlight doesn't output any files / directories at all. It only outputs other stuff like visited emails, Dictionary suggestions, etc. Search (in Finder) doesn't work either.

What I tried:

  1. Waiting for ~12 hours. I can't believe indexing ~220 Gb of content on a 3Gb/s SSD takes so long. Especially considering the zero CPU load.

  2. Rebooting the mac (didn't help) and repeating the whole sequence again, waiting a few seconds before removing the disk from "Privacy" and waiting for quite a long time again.

  3. running sudo mdutil -E / with the same effect as before (high CPU load -> no CPU load -> nothing is indexed).

By the way, running mdutil -s / returns Indexing enabled.

There's no "Indexing" bar in my Spotlight window, if that's important.

Questions

Is there anything else I could try other than waiting for the problem to solve itself or updating to Mojave? Maybe there are more verbose Spotlight logs somewhere or something?

Possibly related question (no answer): Spotlight borked after macOS Sierra update (AskDifferent).

  • did you try deleting Spotlight database ? sudo rm -R .Spotlight-V100/ – Ruskes Sep 26 '18 at 21:48
  • 1
    @Buscar웃 Thanks, trying now... It shows an Indexing bar in the Spotlight window now. A bunch of new mdworkers appeared (there are 11 of them now, which is weird). CPU load is up again. I hope it will index everything correctly this time. I'll let you know of the result. – FreeNickname Sep 26 '18 at 21:55
  • @Buscar웃, unfortunately, the result is the same. I found this thread though, and I'm going to try rebuilding the Lauch Services Database. I'll post my results. – FreeNickname Sep 27 '18 at 9:45
  • 1
    @Buscar웃, fixed it! See my answer below. – FreeNickname Sep 27 '18 at 11:33
6

OK, I solved it, it seems...

The Solution

Run

sudo /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -seed -lint -r -f -v -dump -domain local -domain system -domain user -domain network

killall Dock

sudo mdutil -E /

Not sure if all of these are needed, but that's what worked for me. The first command resets the Launch Sservices Database, the second one resets the Dock, and the third one triggers Spotlight reindexing.

Note that before that I tried running

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user

instead of the first command, and it didn't help. To be more precise, it seemed to have fixed search, but not spotlight.

I also tried sudo rm -R .Spotlight-V100/ suggested in the comments to the question, but it didn't help either.

Details

the issue was in the Launch Services Database. I figured it out by looking at the Console app. There were tons of messages like

errore  16:19:03.743202 +0100   mds LaunchServices: store or url (null) was nil -10813, retrying
errore  16:19:03.743247 +0100   mds LaunchServices: Database mapping failed with result -10813, retries = 7

I found this thread, which led me to trying to reset the Launch Services Database. First I tried the command above that failed. Then I found a fuller (it seems) version of that command, which is posted in the first code block in the "Solution" section above.

  • 1
    This is the only thing that finally fixed Spotlight for me after several days of trying every other solution I could find. Thanks! – Cadin Oct 18 '18 at 20:27

You must log in to answer this question.

protected by Community Feb 11 at 20:53

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged .