MacOS – How to fix locate.updatedb not respecting directory excluded from /etc/locate.rc

bashcommand linemacos

I wanted to exclude some directories from the results of /usr/libexec/locate.updatedb by editing /etc/locate.rc. Unfortunately if I edit locate.rc locate.updatedb runs forever and does not actually terminate — I have to kill it, and then the database for locate is an empty file.

Any ideas on why locate.rc is not respected?

I'm on ML (OS X 10.8), using bash from Macports (bash 4.2.37(2)-release), and my locate.rc reads:

#
# /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 /Users/me/.vim /Users/me/.cups /Users/me/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"

Best Answer

Have you tried the terminal command:

/usr/libexec/locate.updatedb --prune-path="<path>"