Troubleshoot install or upgrade asking for password multiple times

A user reported having a frustrating experience when trying to upgrade Flox and getting asked for their password quite a few different times.

==> Upgrading flox
1.11.4 → 1.12.0
==> Removing launchctl service org.nixos.darwin-store
Password:
Password:
Password:
==> Removing launchctl service org.nixos.nix-daemon
Password:
Password:
Password:
==> Running uninstall script /usr/local/share/flox/scripts/uninstall
Password:
warning: ‘install’ is a deprecated alias for ‘add’
==> Uninstalling packages with `sudo` (which may request your password)…
com.floxdev.flox
Password:
Password:
Password:
Password:
==> Running installer for flox with `sudo` (which may request your password)…
Password:

The MacOS default timeout for sudoers is 5 minutes. You can see if yours is set by running:

sudo -V | grep "Authentication timestamp timeout"

The work-around we found was to edit the timeout to have a value.

A command like this with visudo ensures you do not save incorrect syntax:

sudo visudo -f /etc/sudoers.d/custom_timeout

Then set the file contents to (which would make the default timeout 10 minutes):

Defaults timestamp_timeout=10

Then verify with:

sudo -V | grep "Authentication timestamp timeout"