winget uninstall of a Store/MSIX package fails with 0x80070520 in a non-interactive session
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
- #6597 của @Bearmancer — đã đóng, không merge
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 28/100
Hướng nghiên cứu
Start from src/AppInstallerCLICore/Workflows/UninstallFlow.cpp (MSIX uninstall around the Deployment::RemovePackage call) and src/AppInstallerCommonCore/Deployment.cpp (RemovePackage / WaitForDeployment throwing ExtendedErrorCode 0x80070520). Compare the packaged PackageManager::RemovePackageAsync path with the in-box Remove-AppxPackage behavior in Session 0. Done means uninstall (and related source update) succeeds or fails with a clear non-interactive diagnosis instead of the raw HRESULT.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
This was generated by AI during triage.
Relevant area(s)
WinGet CLI
Relevant command(s)
winget uninstall
Brief description of your issue
winget uninstall of a Store/MSIX package always fails with 0x80070520 : A specified logon session does not exist. It may already have been terminated. when run from a non-interactive session (Session 0: SSH / WinRM / CI / agent). The same failure also breaks winget's own source update (Failed in attempting to update the source: winget).
Root cause is in winget's MSIX uninstall path: Deployment::RemovePackage calls WinRT PackageManager::RemovePackageAsync, whose async result carries ExtendedErrorCode() == 0x80070520; WaitForDeployment re-throws it at Deployment.cpp:54. The AppX deployment broker returns ERROR_NO_SUCH_LOGON_SESSION because winget (running with MSIX package identity) issues the call from a session that has no interactive logon session. The in-box PowerShell cmdlet Remove-AppxPackage succeeds in the identical session, isolating the failure to winget's packaged context.
Steps to reproduce
- Use a machine/shell where the current user has no interactive logon session (SSH / WinRM / Session 0 agent shell).
- Have any Store/MSIX package installed, e.g.
Claude_2.19675.0.0_x64__pzs8sxrjxfjjc. - Run:
winget uninstall claude - Control A (interactive): in the user's interactive session,
winget source updatesucceeds. - Control B (same non-interactive session):
Remove-AppxPackage -Package Claude_2.19675.0.0_x64__pzs8sxrjxfjjcsucceeds.
Expected behavior
The MSIX package is uninstalled, matching the behaviour in an interactive session.
Actual behavior
Found Claude [Anthropic.Claude]
Starting package uninstall...
Uninstall failed with exit code: 0x80070520 : A specified logon session does not exist. It may already have been terminated.
Environment
winget: v1.29.380
Package: Microsoft.DesktopAppInstaller v1.29.380.0
OS: Microsoft Windows 10 Pro 10.0.19045 (build 19045), x64
Shell session: Session 0 (services), IsInteractive=False
gh --version: gh version 2.102.0
git --version: git version 2.55.0.windows.5
Error Logs
winget log (%LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir\WinGet-2026-10-05-19-41-18.880.log):
[CLI ] Found one app. App id: Anthropic.Claude App name: Claude
[CLI ] Removing MSIX package: Claude_2.19675.0.0_x64__pzs8sxrjxfjjc
[CORE] Starting RemovePackage operation #2: Claude_2.19675.0.0_x64__pzs8sxrjxfjjc
[CORE] Begin waiting for operation #2
[CORE] Begin blocking for operation #2
[CORE] Deployment operation #2: A specified logon session does not exist. It may already have been terminated.
[FAIL] ...\AppInstallerCommonCore\Deployment.cpp(54)... Exception(3) ... 80070520 A specified logon session does not exist. It may already have been terminated.
[CLI ] MSIXUninstall uninstaller failed: 2147943712
[CLI ] Terminating context: 0x80070520 at ...\AppInstallerCLICore\Workflows\UninstallFlow.cpp:1f1
2147943712 == 0x80070520.
Event log (Microsoft-Windows-AppXDeploymentServer/Operational):
Id 401: Deployment Remove operation with target volume C: on Package Claude_2.19675.0.0_x64__pzs8sxrjxfjjc from: failed with error 0x80070520.
Id 404: AppX Deployment operation failed for package Claude_2.19675.0.0_x64__pzs8sxrjxfjjc with error 0x80073CFA. The specific error text for this failure is: A specified logon session does not exist. It may already have been terminated.
Root cause
Source read at master @ 39739564a4aaf1071b17d163ec332a08b9bcf05c.
src/AppInstallerCLICore/Workflows/UninstallFlow.cpp:407-434:
407 AICLI_LOG(CLI, Info, << "Removing MSIX package: " << packageFullName.value());
...
416 context.Reporter.ExecuteWithProgress(std::bind(Deployment::RemovePackage, packageFullName.value(), winrt::Windows::Management::Deployment::RemovalOptions::None, std::placeholders::_1));
...
419 catch (const wil::ResultException& re)
...
424 if (isMachineScope && Runtime::IsRunningInPackagedContext() && ...
...
433 context.Add<Execution::Data::OperationReturnCode>(re.GetErrorCode());
434 context << ReportUninstallerResult("MSIXUninstall"sv, re.GetErrorCode(), /* isHResult */ true);
src/AppInstallerCommonCore/Deployment.cpp:267-280:
267 void RemovePackage(std::string_view packageFullName, RemovalOptions options, IProgressCallback& callback)
...
275 PackageManager packageManager;
276 winrt::hstring fullName = Utility::ConvertToUTF16(packageFullName).c_str();
277 auto deployOperation = packageManager.RemovePackageAsync(fullName, options);
279 WaitForDeployment(deployOperation, id, callback);
src/AppInstallerCommonCore/Deployment.cpp:45-54:
45 auto deployResult = deployOperation.get();
47 if (!SUCCEEDED(deployResult.ExtendedErrorCode()))
48 {
49 AICLI_LOG(Core, Error, << "Deployment operation #" << id << ": " << Utility::ConvertToUTF8(deployResult.ErrorText()));
52 if (throwOnError)
54 THROW_HR_MSG(deployResult.ExtendedErrorCode(), "Operation failed: %ws", deployResult.ErrorText().c_str());
The ExtendedErrorCode() is 0x80070520; winget propagates it verbatim. Runtime::IsRunningInPackagedContext() at line 424 shows winget already special-cases packaged-context deployment failures, which supports the packaged/appcontainer explanation.
Counter-scenarios tried
- Interactive-session A/B.
winget source updaterun from a scheduled task in the interactive session succeeded (Updating source: winget... Done; logSuccessfully completed #0). The same command in Session 0 fails with 0x80070520. The interactive session is required. - Independent tool path (isolates packaging). In the identical Session 0, the in-box cmdlet
Remove-AppxPackage -Package Claude_2.19675.0.0_x64__pzs8sxrjxfjjcsucceeded and the package was removed (Get-AppxPackage *Claude*empty;C:\Program Files\WindowsAppsentry gone). The cmdlet is not packaged, so this isolates the failure to winget's packaged process rather than the AppX service or the session itself.
Related issues
- #2537 (closed, Resolution-Duplicate) — "Uninstall via SSH: 'A specified logon session does not exist...' error with several products" — same symptom (
winget uninstall "Phone Link"via SSH). - #5398 (open) — non-interactive
winget downloadfrom msstore, 0x80070520. - #6334 (open) — non-interactive winget source setup fails (
AddPackageAsync), 0x80070520. - #5579, #2495 (closed).
Suggested fix
The logon requirement is enforced by the AppX deployment broker for calls issued from a packaged (appcontainer) process, and winget's MSIX path only uses the in-process PackageManager call. Options: (a) fall back to a non-packaged deployment call (the same call Remove-AppxPackage makes) when the packaged call returns ERROR_NO_SUCH_LOGON_SESSION, or (b) at minimum, translate/diagnose 0x80070520 with an actionable message for the non-interactive case instead of surfacing the raw HRESULT.
- Ngôn ngữ chính
- C++
- Star
- 26.6k
- Fork
- 1.8k
- Merge trung bình
- 3 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 41
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/winget-cli
-
Issue-Docs Needs-Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
microsoft/winget-cli#6692 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Issue-Docs Possible-Duplicate
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
microsoft/winget-cli#6493 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
WinGetSourceCreator: PackWithMappingFile should verify makeappx.exe exists before invoking itĐang mởIssue-Feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
microsoft/winget-cli#6427 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Issue-Docs msstore
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
microsoft/winget-cli#6331 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Command-Source Issue-Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
microsoft/winget-cli#6148 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của microsoft/winget-cli
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
stratum-mining/sv2-tp#167 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Sign up button opens the Sign in page instead of the Sign up page for Enterprise edition serversĐang mởauth bug ui/ux
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
MerginMaps/mobile#4795 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
HarperFast/rocksdb-js#1118 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
26.04 bug dark-mode Easy Hack impress symptom: visual
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
CollaboraOnline/online#16421 · 1 bình luận ·