microsoft/winget-cli

Winget Fails to Honor Custom Installation Path After Uninstall and Reinstall

Opened this issue · 3 comments

Relevant area(s)

PowerShell Module, WinGet CLI

Relevant command(s)

winget install

Brief description of your issue

When using winget to install software with the -l parameter to specify a custom installation path, the path is correctly honored on the first installation. However, after uninstalling and reinstalling the same or a different version of the software, winget ignores the custom path and defaults to the user's AppData directory (e.g., C:\Users\user\AppData\Roaming). This issue is reproducible with multiple packages, such as Tencent.WeChat and JetBrains.IntelliJIDEA.Ultimate, indicating a potential bug in winget's path-handling logic after an uninstall-reinstall cycle.

Steps to reproduce

  1. Run the initial installation command with a custom path, for example: winget install Tencent.WeChat -l "D:\my-software\WinGet\WeChat". Verify that the software is installed correctly in the specified directory.
  2. Uninstall the software using winget or the system uninstaller.
  3. Run the installation command again for the same package or a related version (e.g., winget install Tencent.WeChat.Universal -l "D:\my-software\WinGet\WeChat").
  4. Observe that the software is installed to the default path (C:\Users\user\AppData\Roaming) instead of the custom path.
  5. Optional: Restart the command-line interface and repeat step 3; the issue persists. Test with other packages like JetBrains.IntelliJIDEA.Ultimate to confirm reproducibility.

Expected behavior

Winget should consistently respect the -l parameter and install the software to the specified custom path every time the installation command is executed, regardless of whether the software was previously installed or uninstalled.

Actual behavior

After uninstalling and reinstalling, winget fails to adhere to the custom path specified by -l, automatically falling back to the default user directory (e.g., C:\Users\user\AppData\Roaming). The first installation may work correctly, but subsequent reinstalls exhibit inconsistent behavior.

Environment

PS C:\Windows\system32> winget --info
Windows 程序包管理器 v1.11.510
版权所有 (C) Microsoft Corporation。保留所有权利。

Windows: Windows.Desktop v10.0.26200.6899
系统体系结构: X64
软件包: Microsoft.DesktopAppInstaller v1.26.510.0

Winget 目录
-------------------------------------------------------------------------------------------------------------------
日志                   %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir
用户设置               %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json
可移植链接目录(用户)   %LOCALAPPDATA%\Microsoft\WinGet\Links
可移植链接目录(计算机) C:\Program Files\WinGet\Links
可移植包根目录(用户)   %LOCALAPPDATA%\Microsoft\WinGet\Packages
可移植包根目录         C:\Program Files\WinGet\Packages
可移植包根目录 (x86)   C:\Program Files (x86)\WinGet\Packages
安装程序下载           %USERPROFILE%\Downloads
配置模块               %LOCALAPPDATA%\Microsoft\WinGet\Configuration\Modules

链接
----------------------------------------------------------------------------
隐私声明             https://aka.ms/winget-privacy
许可协议             https://aka.ms/winget-license
第三方声明           https://aka.ms/winget-3rdPartyNotice
主页                 https://aka.ms/winget
Windows 应用商店条款 https://www.microsoft.com/en-us/storedocs/terms-of-sale

管理员设置                                状态
------------------------------------------------
LocalManifestFiles                        已禁用
BypassCertificatePinningForMicrosoftStore 已禁用
InstallerHashOverride                     已禁用
LocalArchiveMalwareScanOverride           已禁用
ProxyCommandLineOptions                   已禁用
DefaultProxy                              已禁用
Trenly commented

@denelon - I initially thought this was a duplicate also, but this appears to be a separate request from the winget upgrade scenario. Specifically, this request seems to be -

  1. A package was installed using winget install <query> -l <location>
  2. The user later uses winget uninstall <query> to uninstall the package
  3. Some amount of time passes (could be 5 minutes, 50 minutes, or 50,000 minutes)
  4. The user runs winget install <query> to install the same app as point 1 (could be the same version or a different one)
  5. The original -l parameter should be respected

I see a few issues with this - such as the use case for wanting to uninstall an app and re-install it in the default location; how the install location would be tracked after uninstall, etc. However, this does seem to be not duplicate

@mos1128 is the observation made by Trenly correct?

Is the request for some mechanism to honor a previous custom location provided for a package after it has been installed, uninstalled, then subsequently reinstalled?

@denelon Yes, his observation is completely correct. However, I found that this doesn't seem to be entirely winget's issue. When I used the -i command to observe, I noticed that the GUI also displayed the installation path as the C drive. So, I think the software, after detecting that it wasn't the first installation (possibly because some residual files were not cleaned up during uninstallation), did not follow winget's path parameter.