microsoft / microsoft/winget-cli

Uninstalling portable package fails with code 0x80070490 (Possibly due to not handling file path encoding correctly)

Open
#4,853 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Brief description of your issue

When installing Ninja-build.Ninja on a new computer I accidentally did so without symlinks. So I was going to uninstall it in order to reinstall it with symlinks enabled. Which go me the following error message:

Found ninja [Ninja-build.Ninja]
Starting package uninstall...
An unexpected error occurred while executing the command:
0x80070490 : Element not found.
Uninstall failed with exit code: 0x80070490 : Element not found.

After checking the logs I suspect that the issue may be due to an encoding issue with the path to the installed executable.
The last part of it looks like this (I have removed parts of my username but not all of it since I suspect it to be the main culprit):

2024-10-04 18:41:45.519 [REPO] Opening database for ReadWrite at 'C:\Users\Söder\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\Microsoft.Winget.Source_8wekyb3d8bbwe\installed.db'
2024-10-04 18:41:45.519 [REPO] Opened SQLite Index with version [1.7], last write [2024-10-04 15:51:26.000]
2024-10-04 18:41:45.530 [REPO] Performing search: Query:[none] Include:PackageFamilyName='Ninja-build.Ninja'[Exact] Include:ProductCode='Ninja-build.Ninja'[Exact] Include:Id='Ninja-build.Ninja'[CaseInsensitive] Include:Name='Ninja-build.Ninja'[CaseInsensitive] Include:Moniker='Ninja-build.Ninja'[CaseInsensitive]
2024-10-04 18:41:45.532 [CORE] Reading cached file [C:\Users\OSKARS~1\AppData\Local\Temp\WinGet\cache\V2_PVD\Microsoft.Winget.Source_8wekyb3d8bbwe\packages\Ninja-build.Ninja\1c36c67c\versionData.mszyml]
2024-10-04 18:41:45.532 [CORE] PackageVersionDataManifest deserializing:
sV: 1.0
vD:
- v: 1.12.1
  rP: manifests/n/Ninja-build/Ninja/1.12.1/018c
  s256H: cdf3028adff6588fb1391fb6d3eea3967109fc734cb9017fa091884dfb4c1007
- v: 1.12.0
  rP: manifests/n/Ninja-build/Ninja/1.12.0/3c33
  s256H: b5c92fc8b10a71f528366de17145b547b796ae5e145dc329d3b3a6e5c0bb2b12
- v: 1.11.1
  rP: manifests/n/Ninja-build/Ninja/1.11.1/3c33
  s256H: a334433198e6f73c07cd53e0ef5b2b430ddbf85f372f5bceb497e5fa955c17fa

2024-10-04 18:41:45.532 [YAML] Detected UTF-8
2024-10-04 18:41:45.538 [REPO] Performing search: Query:[none] Filter:Id='Ninja-build.Ninja'[CaseInsensitive]
2024-10-04 18:41:45.539 [REPO] Finding installed package from available package using system reference search: Query:[none] Include:NormalizedNameAndPublisher='ninja'+'ninjabuild'[Exact]
2024-10-04 18:41:45.539 [REPO] Performing search: Query:[none] Include:NormalizedNameAndPublisher='ninja'+'ninjabuild'[Exact]
2024-10-04 18:41:45.540 [REPO] Performing search: Query:[none] Include:ProductCode='ninja-build.ninja_microsoft.winget.source_8wekyb3d8bbwe'[Exact] Include:NormalizedNameAndPublisher='ninja'+'ninjabuild'[Exact]
2024-10-04 18:41:45.540 [CLI ] Search result size: 1
2024-10-04 18:41:45.540 [CLI ] Found one app. App id: Ninja-build.Ninja App name: ninja
2024-10-04 18:41:45.546 [REPO] Opening database for ReadWrite at 'C:\Users\Söder\AppData\Local\Microsoft\WinGet\Packages\Ninja-build.Ninja_Microsoft.Winget.Source_8wekyb3d8bbwe\ninja-build.ninja_microsoft.winget.source_8wekyb3d8bbwe.db'
2024-10-04 18:41:45.547 [REPO] Opened Portable Index with version [1.0], last write [2024-10-04 15:51:26.000]
2024-10-04 18:41:45.659 [REPO] Opening database for ReadWrite at 'C:\Users\Söder\AppData\Local\Microsoft\WinGet\Packages\Ninja-build.Ninja_Microsoft.Winget.Source_8wekyb3d8bbwe\ninja-build.ninja_microsoft.winget.source_8wekyb3d8bbwe.db'
2024-10-04 18:41:45.659 [REPO] Opened Portable Index with version [1.0], last write [2024-10-04 15:51:26.000]
2024-10-04 18:41:45.659 [REPO] Removing portable file [C:\Users\Söder\AppData\Local\Microsoft\WinGet\Packages\Ninja-build.Ninja_Microsoft.Winget.Source_8wekyb3d8bbwe\ninja.exe]
2024-10-04 18:41:45.660 [REPO] Did not find a portable file with the path  { C:\Users\Söder\AppData\Local\Microsoft\WinGet\Packages\Ninja-build.Ninja_Microsoft.Winget.Source_8wekyb3d8bbwe\ninja.exe }
2024-10-04 18:41:45.660 [FAIL] C:\__w\1\s\external\pkg\src\AppInstallerRepositoryCore\Microsoft\Schema\Portable_1_0\PortableIndexInterface_1_0.cpp(54)\WindowsPackageManager.dll!00007FFDC1EF5036: (caller: 00007FFDC1EC7738) Exception(1) tid(4878) 80070490 Element not found.

2024-10-04 18:41:45.660 [CLI ] Caught wil::ResultException: C:\__w\1\s\external\pkg\src\AppInstallerRepositoryCore\Microsoft\Schema\Portable_1_0\PortableIndexInterface_1_0.cpp(54)\WindowsPackageManager.dll!00007FFDC1EF5036: (caller: 00007FFDC1EC7738) Exception(1) tid(4878) 80070490 Element not found.

2024-10-04 18:41:45.662 [CLI ] PortableUninstall uninstaller failed: 2147943568
2024-10-04 18:41:45.663 [CLI ] Terminating context: 0x8a150057 at C:\__w\1\s\external\pkg\src\AppInstallerCLICore\Workflows\UninstallFlow.cpp:1bd

So as you can see it complains about not being able to find C:\Users\Söder\AppData\Local\Microsoft\WinGet\Packages\Ninja-build.Ninja_Microsoft.Winget.Source_8wekyb3d8bbwe\ninja.exe. The file does however exist (if you correct the encoding issue).

The entry in the sqlite database also does not seem to be faulty (or at least sqlite3.exe handles the encoding correctly):

 ❯ .\sqlite3.exe 'C:\Users\Söder\AppData\Local\Microsoft\WinGet\Packages\Ninja-build.Ninja_Microsoft.Winget.Source_8wekyb3d8bbwe\ninja-build.ninja_microsoft.winget.source_8wekyb3d8bbwe.db'
SQLite version 3.46.1 2024-08-13 09:16:08 (UTF-16 console I/O)
Enter ".help" for usage hints.
sqlite> select * from portable;
C:\Users\Söder\AppData\Local\Microsoft\WinGet\Packages\Ninja-build.Ninja_Microsoft.Winget.Source_8wekyb3d8bbwe\ninja.exe|1|68865c3276d449d746cea5065fdec2baf755d7813e161ab04205b0907b2629b8|
C:\Users\Söder\AppData\Local\Microsoft\WinGet\Links\ninja.exe|3||C:\Users\Söder\AppData\Local\Microsoft\WinGet\Packages\Ninja-build.Ninja_Microsoft.Winget.Source_8wekyb3d8bbwe\ninja.exe
Steps to reproduce

(I do not have the ability to test this with any user account except for my own)

  1. Create a windows user with a name that contains nonascii characters
  2. Log in to the user and run winget install Ninja-build.Ninja
  3. Try to uninstall winget uninstall Ninja-build.Ninja
Expected behavior

Ninja-build.Ninja to be uninstalled.

Actual behavior
Found ninja [Ninja-build.Ninja]
Starting package uninstall...
An unexpected error occurred while executing the command:
0x80070490 : Element not found.
Uninstall failed with exit code: 0x80070490 : Element not found.
Environment
Windows Package Manager v1.8.1911
Windows: Windows.Desktop v10.0.22631.4169
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.23.1911.0

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

Reproduce the uninstall with a Windows username containing non-ASCII characters, then inspect PortableIndexInterface_1_0.cpp around line 54 and the uninstall path reported from UninstallFlow.cpp. Compare the stored portable database paths with the path used during removal; done means winget uninstall removes Ninja-build.Ninja successfully without the 0x80070490 error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.