Search code examples
macoslaunchdspotlight

Spotlight won't turn on: Console says: mds[pid] (Fatal) Server: mds must be run as root. exiting


I turned off spotlight and was very thorough about it. So thorough that I can't get it turned back on. I need to install a program from the Mac App Store (& App Store relies on mds), so if anyone has information on how to install an App Store program without mds at all (spotlight), that would be even better.

So my problem is that spotlight is complaining it can only run as root, but I can't for the life of me figure out why it isn't. From what I understand, launch daemons in /System/Library/LaunchDaemons are automatically launched as root as long as they have the correct permissions. Every file that directory is rw-r-r. Here are the commands I've been using to unload/load spotlight from launchd:

sudo mdutil -a -E -i off
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
sudo rm -rf "/.Spotlight-V100"
sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search

I also rename the mds executables in /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Support, adding a .bak extension.

To reload it, I essentially undo those steps. However it's not working right now. I've searched for the error on google, but no dice. I reloaded the mds binaries from the Snow Leopard install image, didn't do anything. I've repaired permissions 4-5 times and manually looked up the tree to see if I noticed any permissions were wrong, but everything is root:wheel 755 like I assume it should be in the Frameworks folder, and rw-r-r in the LaunchDaemons folder. However mds is constantly spitting messages to the console that say mds[pid] (Fatal) Server: mds must be run as root. exiting.

Anyone have any clue what is going on? I'd rather not reformat right now since I've put quite a long time into setting up this computer and I just want to install one program from the App Store.

Thanks!


Solution

  • Well, wouldn't you know as soon as I break down and post on SO I find the solution: I found someone's spotlight-enable script and pasted it into my terminal. Rebooted, spotlight working, installed program, disabled spotlight again. This is what I used:

    sudo chmod 775 /Library/Spotlight;
    sudo chmod 755 /System/Library/Spotlight;
    sudo chmod 755 /System/Library/PreferencePanes/Spotlight.prefPane;
    sudo chmod 755 /System/Library/Services/Spotlight.service;
    sudo chmod 755 /System/Library/CoreServices/Spotlight.app/Contents/MacOS/Spotlight;
    sudo chmod 555 /usr/bin/mdimport;
    sudo chmod 555 /usr/bin/mdcheckschema;
    sudo chmod 555 /usr/bin/mdfind;
    sudo chmod 555 /usr/bin/mdls;
    sudo chmod 555 /usr/bin/mdutil;
    sudo chmod 555 /usr/bin/md;
    

    As Thilo pointed out, this isn't really programming related so it can be moved to Super User or whatever else anyone things is better.