Trouble with my locate database... "database header corrupt"
I am getting errors when searching my locate database. I deleted and rebuilt but get the same errors.
$ locate -d $HOME/* fuse
locate: locate database header corrupt, bigram char outside 0, 32-127: -1
So I removed it and triggered the warning to check what the proper commands are to rebuild:
$ locate python
WARNING: The locate database (/var/db/locate.database) does not exist.
To create the database, run the following command:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
Please be aware that the database can take some time to generate; once
the database has been created, this message will no longer appear.
Yet,,,, after it's done building I get the same error when running locate and using -d flag.
Is this a Gatekeeper/SIP issue? If so how do I whitelist the locate process?
UPDATE: When I run:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
And look at active Daemons, this is listed. Yet it shows up as "stuck" and is "restricted" in Activity Monitor.
I read on this website that we should do things differently.
- create a central file name database excluding users' home directories
- create individual file name databases for directories and files in a user's home directory.
This is the default content of locate.rc
#
# /etc/locate.rc - command script for updatedb(8)
#
# $FreeBSD: src/usr.bin/locate/locate/locate.rc,v 1.9 2005/08/22 08:22:48 cperciva Exp $
#
# All commented values are the defaults
#
# temp directory
#TMPDIR="/tmp"
# the actual database
#FCODES="/var/db/locate.database"
# directories to be put in the database
#SEARCHPATHS="/"
# directories unwanted in output
#PRUNEPATHS="/tmp /var/tmp"
# filesystems allowed. Beware: a non-listed filesystem will be pruned
# and if the SEARCHPATHS starts in such a filesystem locate will build
# an empty database.
#
# be careful if you add 'nfs'
#FILESYSTEMS="hfs ufs apfs"