microsoft / microsoft/winget-cli

Winget Fails to Honor Custom Installation Path After Uninstall and Reinstall

Open
#5,839 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Command-Upgrade Issue-Bug Possible-Duplicate
Dominant language
C++
Stars
26.4k
Forks
1.8k
Avg merge
1d 11h
Merged PRs (30d)
15

Description

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                              已禁用

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the winget install command and its -l option in the WinGet CLI, then reproduce the uninstall-and-reinstall cycle described for Tencent.WeChat or JetBrains.IntelliJIDEA.Ultimate. Trace how the custom path is handled after uninstall and verify that repeated installations consistently use the requested path rather than the default AppData directory.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, powershell
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.