Skip to content

upgrade and install better handle sudo password prompts #20338

@agowa

Description

@agowa

Verification

Provide a detailed description of the proposed feature

Some packages trigger a sudo password prompt and thereby cause brew to block indefinitely.
When a lot of packages are updated these prompts may be opened way later when the user has already backgrounded the terminal or walked away to grep a cup of coffee while everything installs.

Also it is kinda annoying having to approve sudo multiple times within a run. Therefore in addition it would also be great if brew was aware of which packages request sudo and allow the sudo permission to be granted once in the beginning and then automatically elevates such tasks later on during the run.
However as this most likely would involve some form of IPC it may be complicated to implement.

Also helpful and way less complicated to implement would be allowing to separate the package queue into all packages that can install unattended (aka don't prompt the user, including not for sudo) and ones that do. This way users at least won't be surprised by one of the very first packages in a long list of packages blocking for a password prompt when they previously walked away to "let brew install everything".

Like e.g.:

  • brew upgrade --only-unattended and brew upgrade --only-attended, or
  • brew upgrade --skip-sudo-required and brew upgrade --only-sudo-required.

However I've had a quick look into one of the affected Casks https://github.com/Homebrew/homebrew-cask/blob/main/Casks/m/microsoft-teams.rb and it doesn't appear like we've property that would indicate if a package will be requesting sudo permissions or not. So this may also be difficult in the end.

Finally another approach would be to just hand brew a parameter that tells it to fail a package install upon it requesting sudo. This is the least user friendly way but compared to the others easy to implement and would unblock the queue so that other packages not needing sudo can be installed/upgraded. The affected packages would then be installed/upgraded when a user re-runs brew without that flag. E.g. brew upgrade --fail-package-on-sudo or more generically brew upgrade --timeout-wait-for-user=10s.

What is the motivation for the feature?

The user experience for dealing with packages that need user interaction while installing/upgrading like e.g. by request sudo (e.g. https://github.com/Homebrew/homebrew-cask/blob/main/Casks/m/microsoft-teams.rb) is currently quite bad and there are no good workarounds at the moment either.

How will the feature be relevant to at least 90% of Homebrew users?

Considering how "popular" at least the microsoft-teams package is I'd say it is relevant to a lot of users, as there probably will often be a package within the upgrade queue that block until a user grants them sudo permissions.

What alternatives to the feature have been considered?

See above multiple alternatives are provided. Without brew however there is none except keeping a manual list of packages that need it and manually group packages into different lists for updating. Which however only works as long as there aren't any dependencies between these two groups pulling something needing sudo in while trying to update the group without....

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedWe want help addressing this

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions