Context
ChocoBackend sets requires_root = False because Windows has no sudo
and pkgwrap cannot elevate a running process. But Chocolatey genuinely
needs an elevated (Administrator) shell for install and remove. Today the
user only finds out when choco itself fails, with a message that doesn't
mention pkgwrap at all.
WindowsBackend (winget) doesn't have this problem — winget raises its own
UAC prompt when it needs elevation.
Proposal
Detect elevation on Windows and print a clear warning before running a
choco command that needs it:
import ctypes
ctypes.windll.shell32.IsUserAnAdmin()
The warning should say what to do ("run this from an Administrator
PowerShell or Command Prompt"), not just that something is wrong. This
should be a warning, not a hard failure — the user may have choco
configured differently.
Acceptance criteria
Pointers
src/pkgwrap/backends/choco_backend.py
src/pkgwrap/backends/brew_backend.py has a similar warning for the
opposite problem (brew refuses to run as root) — follow that pattern
Context
ChocoBackendsetsrequires_root = Falsebecause Windows has nosudoand pkgwrap cannot elevate a running process. But Chocolatey genuinely
needs an elevated (Administrator) shell for install and remove. Today the
user only finds out when choco itself fails, with a message that doesn't
mention pkgwrap at all.
WindowsBackend(winget) doesn't have this problem — winget raises its ownUAC prompt when it needs elevation.
Proposal
Detect elevation on Windows and print a clear warning before running a
choco command that needs it:
The warning should say what to do ("run this from an Administrator
PowerShell or Command Prompt"), not just that something is wrong. This
should be a warning, not a hard failure — the user may have choco
configured differently.
Acceptance criteria
no-op elsewhere (Linux/macOS/CI runners)
chocoinstall/remove/upgrade warn when not elevatedmocked
Pointers
src/pkgwrap/backends/choco_backend.pysrc/pkgwrap/backends/brew_backend.pyhas a similar warning for theopposite problem (brew refuses to run as root) — follow that pattern