When I run sudo /usr/libexec/locate.updatedb to manually update the locate database, I get this error:

❯ sudo /usr/libexec/locate.updatedb
mktemp: too few Xs in template ‘updatedb’
chown: missing operand after ‘nobody’
Try 'chown --help' for more information.
/usr/libexec/locate.updatedb: line 102: /var/db/locate.database: Permission denied
rm: missing operand
Try 'rm --help' for more information.

How do I resolve this?


The reason you hit this is because you have the GNU mktemp as the first item in your path.

You can verify this by running, type -a mktemp. If you don't see /usr/bin/mktemp as the first option then that is likely your issue.

For example I have:

❯ type -a mktemp
mktemp is /usr/local/opt/coreutils/libexec/gnubin/mktemp
mktemp is /usr/bin/mktemp

The reason I hit this is that I have run brew install coreutils, and then followed the option in the caveats section:

Commands also provided by macOS have been installed with the prefix "g".
If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:

This can put the GNU mktemp ahead of the macOS one.

The fix is simply to stop doing that, remove the above line and just use the g-prefixed versions (e.g. gmktemp) when you need GNU tools.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .