Locate database does not exist, even though it is already loaded
I am trying to use the locate command because even though I installed postgresql, psql is not recognized on command line:
$ locate psql | grep /bin
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.
So I run the command:
$ sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
com.apple.locate: Already loaded
Output:
$ ls -l /var/db/locate.database
-r--r--r-- 1 nobody wheel 11096658 Mar 25 14:29 /var/db/locate.database
If it is already loaded, then why is it telling me to create the database? I already created it. How can I get locate working?
Solution 1:
You can update the database used by locate
manually by running
sudo /usr/libexec/locate.updatedb