Running "brew" using su -u?

I use my Mac daily with a non admin user account. When updating brew I open terminal and “su admin” to log into my admin account—then run brew update and upgrade.

Recently, when trying to un-install a package that required login permissions I was blocked by MacOS because I didn’t have access/permission in Security Preferences. The option to give access never appeared. This was because I was still logged into my user account —not my admin account. I had to log out of my user account and into my admin account to run that uninstall command to get the access prompt from Security Preferences.

The question is would it be better, or solve that issue to use “su admin -u” instead of just “su admin” when running brew in my non admin user account?

I tried logging in that way and received a warning:

$ su admin -u
bash: HOMEBREWDIR: unbound variable

Why -u? That makes your su effectively equivalent to:

su admin bash -l -u

which runs an interactive login shell as user admin…and complains about reading unset variables (i.e. as if you’d typed set -u). That seems to be completely unrelated to your issue, and instead creates a new one.

1 Like

Thanks, that’s why I ask the pros!