winget SQL error

%3CLINGO-SUB%20id%3D%22lingo-sub-3066428%22%20slang%3D%22en-US%22%3Ewinget%20SQL%20error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3066428%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20winget%20command%20fails%20with%20SQL%20error%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%20class%3D%22lia-spoiler-container%22%3E%3CA%20class%3D%22lia-spoiler-link%22%20href%3D%22%23%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3ESpoiler%3C%2FA%3E%3CNOSCRIPT%3E(Highlight%20to%20read)%3C%2FNOSCRIPT%3E%3CDIV%20class%3D%22lia-spoiler-border%22%3E%3CDIV%20class%3D%22lia-spoiler-content%22%3E%3CP%3EAn%20unexpected%20error%20occurred%20while%20executing%20the%20command%3A%3C%2FP%3E%3CP%3ESQL%20logic%20error%3C%2FP%3E%3CP%3E0x87af0001%20%3A%20SQL%20error%20or%20missing%20database%3C%2FP%3E%3C%2FDIV%3E%3CNOSCRIPT%3E%3CDIV%20class%3D%22lia-spoiler-noscript-container%22%3E%3CDIV%20class%3D%22lia-spoiler-noscript-content%22%3EAn%20unexpected%20error%20occurred%20while%20executing%20the%20command%3ASQL%20logic%20error0x87af0001%20%3A%20SQL%20error%20or%20missing%20database%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FNOSCRIPT%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20a%20way%20to%20solve%20this%20issue%20%3F%3C%2FP%3E%3CP%3E(Windows%2011%2022523)%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi,

The winget command fails with SQL error

 

Spoiler

An unexpected error occurred while executing the command:

SQL logic error

0x87af0001 : SQL error or missing database

 

Is there a way to solve this issue ?

(Windows 11 22523, Winget v1.2.3411-preview)

2 Replies

@plo3000 I was recently having the same issue. Seems like it has to do with the cache for apps installed from the MS Store being corrupted. I was able to resolve it by deleting %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\StoreEdgeFD\installed.db

If that doesn't fix it, you can better diagnose the issue by taking a look at the logs in %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir\

Here are my relevant logs for reference:

Spoiler
2022-02-24 15:58:00.760 [REPO] Opening SQLite Index for ReadWrite at 'C:\Users\teomi\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\StoreEdgeFD\installed.db'
2022-02-24 15:58:00.760 [SQL ] Opening SQLite connection: 'C:\Users\teomi\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\StoreEdgeFD\installed.db' [2, 0]
2022-02-24 15:58:00.761 [FAIL] D:\a\_work\1\s\external\pkg\src\AppInstallerRepositoryCore\SQLiteWrapper.cpp(173)\WindowsPackageManager.dll!00007FF841A8121A: (caller: 00007FF841A821B6) Exception(1) tid(2b64) 87AF0001 SQL error or missing database
Msg:[SQL logic error]

2022-02-24 15:58:00.761 [CLI ] Caught wil::ResultException: D:\a\_work\1\s\external\pkg\src\AppInstallerRepositoryCore\SQLiteWrapper.cpp(173)\WindowsPackageManager.dll!00007FF841A8121A: (caller: 00007FF841A821B6) Exception(1) tid(2b64) 87AF0001 SQL error or missing database
Msg:[SQL logic error]

 

Thank you @jamonith , I was having the same issue and your solution worked for me