Open aetonsi opened 1 month ago
can confirm it works when running as admin:
# topgrade -v --only=node
── 23:44:02 - Node Package Manager ─────────────────────────────────────────────
DEBUG Executing command `C:\Program Files\nodejs\npm.cmd --version`
DEBUG Executing command `C:\Program Files\nodejs\npm.cmd update '--location=global'`
changed 105 packages in 14s
DEBUG Desktop notification: Summary
── 23:44:16 - Summary ──────────────────────────────────────────────────────────
npm: OK
DEBUG Desktop notification: Topgrade finished successfully
This configuration is currently Linux-only, on Windows, the parameter is simply set to false
:
The reason is probably that we don't know how to do this on Windows. This configuration works in this way:
If you have sudo
installed, it checks if the current Topgrade process is capable of modifying the NPM file, if not, sudo
will be used. On an UNIX OS, Topgrade checks the privilege by checking if the effective user ID of the Topgrade process equals to the user ID of the owner of the NPM file, both EUID and file owner are concepts of UNIX, we need the counterparts on Windows to implement this configuration.
oh i see.. if it can be useful, fyi here's how on windows you can both check if a user is admin and elevate if necessary.
https://serverfault.com/a/95464
(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
https://github.com/gerardog/gsudo#usage-from-powershell--powershell-core
gsudo some-command /with /parameters --and --whatnot
gsudo can also "cache" the administrative privilege if needed: https://github.com/gerardog/gsudo?tab=readme-ov-file#credentials-cache
Erroneous Behavior
Npm errors out about permissions (err -4048):
Expected Behavior
topgrade should use (g)sudo to elevate the operation automatically
Steps to reproduce / Possible Cause (Optional)
simply, i think i had installed things while running as administrator, while now i'm trying to use topgrade NOT as admin
Problem persists without calling from topgrade
Did you run topgrade through
Remote Execution
If yes, does the issue still occur when you run topgrade directlly in your remote host
Configuration file (Optional)
Additional Details
Microsoft Windows [Version 10.0.22635.3066]
)topgrade -V
):15.0.0
Verbose Output (
topgrade -v
)command:
topgrade -v --only=node