From a70a66defa30f2eed77868f4bf7722b713e050da Mon Sep 17 00:00:00 2001 From: Federico Justus Denkena Date: Sat, 12 Sep 2026 13:14:33 +0200 Subject: [PATCH] windows/bootstrap: repair empty winget source before install 0x8a15000f ("Data required by the source is missing") aborts Git.Git / GoLang.Go install on a virgin DesktopAppInstaller cache, then iex dies on missing git. Reset+update the source once, pin --source winget, retry without the pin, then fail loudly if the index is still empty. --- windows/bootstrap.ps1 | 53 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/windows/bootstrap.ps1 b/windows/bootstrap.ps1 index 10caa91..08c1a9a 100644 --- a/windows/bootstrap.ps1 +++ b/windows/bootstrap.ps1 @@ -11,14 +11,61 @@ $Dest = Join-Path $env:LOCALAPPDATA 'rclone-dropbox-bisync' $Dropbox = 'D:\Dropbox' $Workdir = 'D:\rclone-bisync' +function Refresh-Path { + $env:Path = [Environment]::GetEnvironmentVariable('Path', 'Machine') + ';' + + [Environment]::GetEnvironmentVariable('Path', 'User') +} + +# 0x8a15000f: winget source index missing/corrupt (common on a fresh DesktopAppInstaller). +function Repair-WingetSource { + if ($script:WingetSourceRepaired) { return } + $winget = Get-Command winget -ErrorAction SilentlyContinue + if (-not $winget) { return } + $prev = $ErrorActionPreference + $ErrorActionPreference = 'Continue' + try { + & winget source reset --force --disable-interactivity 2>&1 | Out-Null + & winget source update --disable-interactivity 2>&1 | Out-Null + } finally { + $ErrorActionPreference = $prev + } + $script:WingetSourceRepaired = $true +} + +function Install-WithWinget($WingetId) { + Repair-WingetSource + $wingetArgs = @( + 'install', '-e', '--id', $WingetId, + '--accept-package-agreements', '--accept-source-agreements', + '--disable-interactivity', '--source', 'winget' + ) + $prev = $ErrorActionPreference + $ErrorActionPreference = 'Continue' + try { + & winget @wingetArgs + if ($LASTEXITCODE -eq 0) { return } + # Index still empty: reset once more, then retry without pinning the source + # (some hosts only have msstore until cdn.winget.microsoft.com is reachable). + & winget source reset --force --disable-interactivity 2>&1 | Out-Null + & winget source update --disable-interactivity 2>&1 | Out-Null + & winget install -e --id $WingetId --accept-package-agreements --accept-source-agreements --disable-interactivity + if ($LASTEXITCODE -eq 0) { return } + } finally { + $ErrorActionPreference = $prev + } + throw "winget failed to install $WingetId (exit $LASTEXITCODE / 0x8a15000f = empty source cache). Run: winget source reset --force; winget source update" +} + function Ensure-Cmd($Name, $WingetId) { if (Get-Command $Name -ErrorAction SilentlyContinue) { return } if (-not (Get-Command winget -ErrorAction SilentlyContinue)) { throw "Need $Name on PATH (or winget to install $WingetId)" } - winget install -e --id $WingetId --accept-package-agreements --accept-source-agreements - $env:Path = [Environment]::GetEnvironmentVariable('Path', 'Machine') + ';' + - [Environment]::GetEnvironmentVariable('Path', 'User') + Install-WithWinget $WingetId + Refresh-Path + if (-not (Get-Command $Name -ErrorAction SilentlyContinue)) { + throw "$Name still missing after winget install $WingetId; open a new PowerShell and retry" + } } Ensure-Cmd git Git.Git