microsoft / microsoft/winget-cli

Figured out how to fix Windows Store/winget corrupt repository

Open
#4,513 13 comments 22 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Brief description of your issue

This is the corrupt repository issue that causes Microsoft Store error 0x80073CFE and Winget complaining the repository is corrupt.

Steps to reproduce

It just breaks.

Expected behavior

Shouldn't break, should recover if broken.

Actual behavior

The only way to fix it, allegedly, is to reinstall Windows. Reinstalling while keeping your applications won't work; you need clean reinstall. wsreset, dism, and other commands don't fix it.

Environment

Windows 11

Fix

After a day, the final resolution was to boot into a recovery console (or Linux) and go to C:\ProgramData\Microsoft\Windows\AppRepository, back up everything that starts with StateRepository-, then use sqlite3 StateRepository-{whatever}.srd ".restore" | sqlite3 {new dbname}.srd and move the newly-created .srd over the original. You can check if one is broken by opening it with sqlite3 and running PRAGMA integrity_check.

If you delete these files, Windows will become very broken. Take backups before messing with them.

winget and the Microsoft Store (or State Repository Service) should make periodic backups and do an occasional integrity check, and alert the user if the database is corrupt, running either a ".restore" or restoring from a recent backup. You could back up every day for like 5 days and it wouldn't be a problem, run an integrity check and then make a full copy of the database.

It is massively, massively broken that this infrastructure requires a clean reinstall of Windows unless you know specific details about how winget and the Microsoft Store work.

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 by reviewing how winget and the State Repository Service interact with the StateRepository-*.srd databases under C:\ProgramData\Microsoft\Windows\AppRepository, then reproduce the sqlite3 PRAGMA integrity_check and .restore steps described. Done would need a defined, tested design for periodic backups, corruption detection, recovery, and user alerts; the issue does not identify implementation files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, sqlite
Domain
cli, databases, operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.