MACOS使用locate命令一直提示:WARNING: The locate database (/var/db/locate.database) does not exist. To create the database, run the following command

现象

在macOS上使用locate命令查找文件的时候,报错如下:

 $ locate jdk 

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.

按照系统的提示,使用sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist这个命令,提示如下:

$ sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

Password:
/System/Library/LaunchDaemons/com.apple.locate.plist: service already loaded

然后再次使用locate命令,仍旧是提示上面的错误,db不存在。

解决方法

使用命令sudo /usr/libexec/locate.updatedb,直接更新locate的db,等几分钟后再使用locate命令。

posted @ 2021-01-20 12:09  于果alpha  阅读(530)  评论(0编辑  收藏  举报