13

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).

4
  • did you try deleting Spotlight database ? sudo rm -R .Spotlight-V100/
    – Ruskes
    Commented Sep 26, 2018 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. Commented Sep 26, 2018 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. Commented Sep 27, 2018 at 9:45
  • 1
    @Buscar웃, fixed it! See my answer below. Commented Sep 27, 2018 at 11:33

1 Answer 1

16

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.

5
  • 3
    This is the only thing that finally fixed Spotlight for me after several days of trying every other solution I could find. Thanks!
    – Cadin
    Commented Oct 18, 2018 at 20:27
  • THIS IS THE ANSWER Y'ALL ARE LOOKING. 100% REAL NO FAKE
    – Orlando
    Commented Nov 14, 2019 at 1:55
  • I am not sure what command you drew from that separate thread. too many answers there. dont want to break anything.
    – mjs
    Commented Nov 26, 2019 at 14:04
  • @momomo, which thread are you referring to? I ended up using 3 commands that are listed in the code block in this answer. Other things didn't seem to help. However, by all means play it safe if you're worried, and I would recommend making a TimeMachine backup before doing the manipulations above. Although, at least from my understanding, they shouldn't break anything, but backups never hurt. Commented Nov 27, 2019 at 7:03
  • 1
    This worked for me. I had almost given up when I found those log entries, which led me here. Thanks for the answer! Commented May 19, 2020 at 16:41

You must log in to answer this question.

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