Creating 'locate' database on MacOS

December 25, 2019

So i was trying to use the locate command to find config file on my Mac and it give me this message upon executing the command:

$ locate <some-file>

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/

Please be aware that the database can take some time to generate; once
the database has been created, this message will no longer appear.

as the message says, mlocate system cant find it's database of on the system. and it says i just need to run those line of command to create one, a little different from what i usually do on other unix system that i can just simply run updatedb

Probably just another Mac thing so i just follow what i was told, but nope, it's never that simple, it giving me this instead:

/System/Library/LaunchDaemons/ service already loaded

Well, also trying to execute locate just in case it actually do something, but no, It still giving me the same exact message. And no matter how long i wait (assuming the command are still creating the db on the background) but it's still fail.

it appears to create the database, i can just use updatedb function just like usual. and it appears it was placed on libexec directory with different naming instead the ususal updatedb on the bin directory.

With that said, simply executing this and wait for a few second for it to create the database and you're ready to go to use locate command again:

$ sudo /usr/libexec/locate.updatedb

Well...i don't even know what to say~

Get in Touch