Skip to content

macOS: keep Spotlight's file results off, and add a way to stop the indexer - #83

Merged
landsman merged 2 commits into
mainfrom
macos-spotlight
Aug 12, 2026
Merged

macOS: keep Spotlight's file results off, and add a way to stop the indexer#83
landsman merged 2 commits into
mainfrom
macos-spotlight

Conversation

@landsman

Copy link
Copy Markdown
Owner

Two separate things, because they turn out to be separate mechanisms: which rows Spotlight is allowed to show, and whether mds indexes files at all.

Why

A kernel panic on 2026-08-12, #82. The vnode table filled up (263168 numvnodes, 0 free) while mds reindexed a monorepo behind several coding agents, APFS could no longer create vnodes, every mmapped page after that faulted with SIGBUS, launchd took one and the kernel panicked with initproc exited.

The results half — bin/macos/defaults.sh

defaults write com.apple.Spotlight EnabledPreferenceRules -array Custom.relatedContents … System.files System.folders System.iphoneApps

The key name lies: EnabledPreferenceRules lists what is turned off. Read, not guessed — defaults read was snapshotted, the Files and Folders switches flipped, and those two entries appeared in the array. A row left at Apple's default is simply absent, so the whole array is the state and adding a line means switching something off.

This does not stop indexing. With both switches off, a probe file dropped in ~/projects was in mdfind twenty seconds later. It filters what Spotlight shows, and that is all.

The indexer half — make macos-spotlight-off

sudo mdutil -i off -d /System/Volumes/Data

A whole volume, because nothing finer exists:

  • man mdutil, man mds, man mdimport, man mdfind — not one mention of exclusions. A volume is the only granularity Apple documents.
  • .metadata_never_index in ~/projects — tested, changed nothing.
  • The Privacy list in System Settings does work, but it lives in /System/Volumes/Data/.Spotlight-V100/VolumeConfiguration.plist, which TCC hides even from root: PlistBuddy reports File Doesn't Exist for a file sudo mdutil -P prints happily. Scripting it needs Full Disk Access handed to whichever terminal runs it, and it is undocumented besides.

Costs Finder's "This Mac" search. App results (Mail, Notes, Messages) come from CoreSpotlight and are expected to survive — that is the one claim here not verified live, and it says so in the Makefile.

Its own target, not part of make macos: that one writes nothing outside $HOME and asks for no password, same reason macos-touchid stands alone. macos-spotlight-on reverses it.

Conflicts with #32

#32 (draft) adds a check that warns from make macos when too few apps are indexed, pointing at sudo mdutil -E /. With indexing off that check nags forever, and both branches touch bin/macos/defaults.sh. Whichever lands second needs the other taken into account — the check would have to skip when mdutil -s reports indexing disabled.

Checks

make lint bin-test passes. defaults.test.sh asserted a hardcoded domain count, 11 → 12. Neither make macos nor make macos-spotlight-off was run as part of preparing this.

The Spotlight pane's own switches are a results filter and nothing more:
with Files and Folders both off, a probe file dropped in ~/projects was
still in `mdfind` twenty seconds later. So the two halves are separate
here — `defaults.sh` records which rows are off, and a new target stops
`mds` from indexing at all.

The array name lies. `EnabledPreferenceRules` lists what is turned *off*;
`System.files` and `System.folders` appeared in it the moment those two
switches went dark, which is how the list was read rather than guessed.

Why the indexer half is a whole volume and not ~/projects: nothing else
works. `man mdutil`, `man mds`, `man mdimport` and `man mdfind` between
them say nothing about exclusions. `.metadata_never_index` in the folder
changed nothing. The Privacy list does work, but its plist is behind TCC
even for root, so scripting it needs Full Disk Access on the terminal —
and is undocumented anyway.

The motive is a kernel panic on 2026-08-12: the vnode table filled up
while mds reindexed a monorepo behind several coding agents, every
mmapped page after that faulted with SIGBUS, launchd took one and the
kernel had nowhere to go.
"Help Apple Improve Search" hands Safari, Siri, Spotlight and Lookup
queries to Apple, and the key does not exist until the switch is touched
— absent means opted in, which is why it belongs in a file rather than in
a memory of having clicked it once.

2 is the opted-out value, taken from what the switch itself wrote rather
than from a guess: `defaults read` was diffed across the flip.
@landsman landsman changed the title Keep Spotlight's file results off, and add a way to stop the indexer macOS: keep Spotlight's file results off, and add a way to stop the indexer Aug 12, 2026
@landsman
landsman merged commit c5a899d into main Aug 12, 2026
3 checks passed
@landsman
landsman deleted the macos-spotlight branch August 12, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant