Recently, after updating Homebrew on macOS High Sierra (v10.13.6), I began experiencing a locate
error every time I logged into a mac Terminal window. The error message was as follows:
locate: locate database header corrupt, bigram char outside 0, 32-127: -1
I found some information on this error online, here, and decided to use it, first removing the locate database, as follows:
rm -rf /var/db/locate.database
but this created its own set of problems. Now, instead of loading correctly, I got a new error message stating that the locate database did not exist. The new error was as follows:
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.
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.
The usually recommended fix for this issue, I learned, was to regenerate the database, but the following common method for this also failed:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
… giving the same “…does not exist…” error set as shown above.
What finally worked for me was to generate the locate
database anew (it took a long time!) using the following command, recommended in this post on OSXDaily:
sudo /usr/libexec/locate.updatedb
After the new locate
database was generated, Terminal loaded normally and all locate
-related errors stopped, and I continue to have no issues with locate
. I hope that this helps someone who runs across this problem in the future.
~J