MacOS – sudo: unable to cache user root, already exists

macospermissionsudoterminal

Suddenly started getting this strange error when attempting to run any command via sudo:

sudo: unable to cache user root, already exists

I've tried different Terminal windows, repairing permissions, restarting, and tried creating a new admin user but still get the same issue. As far as OS X is concerned I'm still an administrator and can perform any actions that open an administrator's password dialogue box, but I can no longer run any command via Terminal that requires the use of sudo.

Does anyone know where the cache that sudo is mentioning might be located, and whether I can delete and recreate it (and if so, how if it isn't a simple delete)? Is there any other way to solve this issue?

Best Answer

It seems that in my case I was able to repair the problem while writing my question, by reading the man pages more closely and running the following command:

sudo -k

This command revokes all outstanding sudo permissions and forces you to re-enter your password the next time that sudo is used.

However, I've been unable to discover why this issue presented itself in the first place, but wanted to post my solution nonetheless for the benefit of anyone else that encounters this problem. If someone knows why it might happen then please feel free to comment or add to this answer!