microsoft / winget-cli

WinGet is the Windows Package Manager. This project includes a CLI (Command Line Interface), PowerShell modules, and a COM (Component Object Model) API (Application Programming Interface).
https://learn.microsoft.com/windows/package-manager/
MIT License
23.28k stars 1.45k forks source link

winget upgrade git.git clobbers user environment variables #2781

Open blakeduffey opened 1 year ago

blakeduffey commented 1 year ago

Brief description of your issue

I use winget install --id Git.Git as a way to provide users both the git client as well as the updated version of the OpenSSH client. This provides users an updated version of both apps without needing local admin (which our corporate users don't have).

I then add two folders to the local users PATH via

[Environment]::SetEnvironmentVariable("PATH", $Env:PATH + ";$env:LOCALAPPDATA\Programs\Git\bin;$env:LOCALAPPDATA\Programs\Git\usr\bin", [EnvironmentVariableTarget]::User)

This way both git and ssh are in the PATH (and can be run from any directory).

The problem is - when I perform winget upgrade git.git - it clobbers those path entries (and I have to re-add them each time). This seems like something that could be improved?

Steps to reproduce

winget upgrade git.git

Expected behavior

local path changes would be retained

Actual behavior

local path is clobbered

Environment

Windows Package Manager v1.3.2691
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.19044.2364
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.18.2691.0
denelon commented 1 year ago

I'm not sure if there are any arguments that could be passed to the installer to modify its behavior. That would be the first thing I would check.

We're looking into some of the challenges with installers and environment variables as a part of the dependency support work in progress.