Romanitho / Winget-AutoUpdate

WAU daily updates apps as system and notify connected users. (Allowlist and Blocklist support)
MIT License
996 stars 128 forks source link

[Bug]: Update often fails. #363

Closed guzy0324 closed 1 year ago

guzy0324 commented 1 year ago

The problem

The WAU update often fails, but winget upgrade --all works fine.

找不到与输入条件匹配的已安装程序包。 in the log means No package found matching input criteria..

I suspect that the failure is caused by wrong application id:

10:41:01 - Updating 腾讯会议                                                       Te from 18.3.433 to 3.18.4.441...
10:41:04 - ##########   WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID 'ncent.TencentMeeting       3.'   ##########
10:41:04 - -> Running: Winget upgrade --id ncent.TencentMeeting       3. --accept-package-agreements --accept-source-agreements -h

   - 
   \ 

   - 

找不到与输入条件匹配的已安装程序包。
10:41:08 - -> An upgrade for 腾讯会议                                                       Te failed, now trying an install instead...
10:41:08 - -> Running: Winget install --id ncent.TencentMeeting       3. --accept-package-agreements --accept-source-agreements -h

   - 

   - 

找不到与输入条件匹配的程序包。
10:41:12 - ##########   WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID 'ncent.TencentMeeting       3.'   ##########
10:41:12 - 腾讯会议                                                       Te update failed.

The name and id of the app shown in log are 腾讯会议 Te and ncent.TencentMeeting, while they should be 腾讯会议 and Tencent.TencentMeeting.

What version of WAU has the issue?

1.17.5

What version of Windows are you using (ex. Windows 11 22H2)?

Windows 11 22H2

What version of winget are you using?

2023.720.146.667

Log information

##################################################
#     CHECK FOR APP UPDATES - 2023/7/20
##################################################
10:40:51 - Running in User context
10:40:51 - Notification Level: Full. Notification Language: English
10:40:51 - Checking internet connection...
10:40:52 - Connected !
10:40:58 - Winget Version: v1.5.1572
10:40:58 - WAU current version: 1.17.5
10:40:58 - WAU uses Black List config
10:40:58 - Checking application updates on Winget Repository...
-> Available update : 腾讯会议                                                       Te. Current version : 18.3.433. Available version : 3.18.4.441.
-> Available update : Microsoft Edge. Current version :   114.0.1823. Available version : .82 114.0.1823.86.
-> Available update : Microsoft Visual C++ 2015-2022 Redistributable (x86) - 14.34.. Current version : 6 14.34.3193. Available version : 8.0 14.36.32532.0.
-> Available update : 阿里云盘                                                       Al. Current version : 5.0. Available version : 4.6.1.
-> Available update : 哔哩哔哩直播姬                                                 Bilib. Current version : 0.5019   4.4. Available version : 8.0.5057.
-> Available update : Clash for Windows 0.20.28. Current version :   0.20.28. Available version :     0.20.29.
-> Available update : Oh My Posh version 17.11.2. Current version :   17.11.2. Available version :     17.11.3.
-> Available update : Epic Games Launcher. Current version :   1.3.67.0. Available version :     1.3.78.0.
10:41:01 - Updating 腾讯会议                                                       Te from 18.3.433 to 3.18.4.441...
10:41:04 - ##########   WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID 'ncent.TencentMeeting       3.'   ##########
10:41:04 - -> Running: Winget upgrade --id ncent.TencentMeeting       3. --accept-package-agreements --accept-source-agreements -h

   - 
   \ 

   - 

找不到与输入条件匹配的已安装程序包。
10:41:08 - -> An upgrade for 腾讯会议                                                       Te failed, now trying an install instead...
10:41:08 - -> Running: Winget install --id ncent.TencentMeeting       3. --accept-package-agreements --accept-source-agreements -h

   - 

   - 

找不到与输入条件匹配的程序包。
10:41:12 - ##########   WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID 'ncent.TencentMeeting       3.'   ##########
10:41:12 - 腾讯会议                                                       Te update failed.
10:41:15 - Updating Microsoft Edge from   114.0.1823 to .82 114.0.1823.86...
10:41:18 - ##########   WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '  Microsoft.Edge'   ##########
10:41:18 - -> Running: Winget upgrade --id   Microsoft.Edge --accept-package-agreements --accept-source-agreements -h

   - 

   - 

找不到与输入条件匹配的已安装程序包。
10:41:21 - -> An upgrade for Microsoft Edge failed, now trying an install instead...
10:41:21 - -> Running: Winget install --id   Microsoft.Edge --accept-package-agreements --accept-source-agreements -h

   - 

   - 

找不到与输入条件匹配的程序包。
10:41:25 - ##########   WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID '  Microsoft.Edge'   ##########
10:41:25 - Microsoft Edge update failed.
10:41:28 - Updating Microsoft Visual C++ 2015-2022 Redistributable (x86) - 14.34. from 6 14.34.3193 to 8.0 14.36.32532.0...
10:41:31 - ##########   WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '… Microsoft.VCRedist.2015+.x8'   ##########
10:41:31 - -> Running: Winget upgrade --id … Microsoft.VCRedist.2015+.x8 --accept-package-agreements --accept-source-agreements -h

   - 

   - 

找不到与输入条件匹配的已安装程序包。
10:41:34 - -> An upgrade for Microsoft Visual C++ 2015-2022 Redistributable (x86) - 14.34. failed, now trying an install instead...
10:41:34 - -> Running: Winget install --id … Microsoft.VCRedist.2015+.x8 --accept-package-agreements --accept-source-agreements -h

   - 

   - 

找不到与输入条件匹配的程序包。
10:41:37 - ##########   WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID '… Microsoft.VCRedist.2015+.x8'   ##########
10:41:37 - Microsoft Visual C++ 2015-2022 Redistributable (x86) - 14.34. update failed.
10:41:41 - Updating 阿里云盘                                                       Al from 5.0 to 4.6.1...
10:41:44 - ##########   WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID 'ibaba.aDrive               4.'   ##########
10:41:44 - -> Running: Winget upgrade --id ibaba.aDrive               4. --accept-package-agreements --accept-source-agreements -h

   - 

   - 

找不到与输入条件匹配的已安装程序包。
10:41:47 - -> An upgrade for 阿里云盘                                                       Al failed, now trying an install instead...
10:41:47 - -> Running: Winget install --id ibaba.aDrive               4. --accept-package-agreements --accept-source-agreements -h

   - 
   \ 

   - 

找不到与输入条件匹配的程序包。
10:41:51 - ##########   WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID 'ibaba.aDrive               4.'   ##########
10:41:51 - 阿里云盘                                                       Al update failed.
10:41:54 - Updating 哔哩哔哩直播姬                                                 Bilib from 0.5019   4.4 to 8.0.5057...
10:41:57 - ##########   WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID 'ili.Livehime            4.47.'   ##########
10:41:57 - -> Running: Winget upgrade --id ili.Livehime            4.47. --accept-package-agreements --accept-source-agreements -h

   - 

   - 

找不到与输入条件匹配的已安装程序包。
10:42:00 - -> An upgrade for 哔哩哔哩直播姬                                                 Bilib failed, now trying an install instead...
10:42:00 - -> Running: Winget install --id ili.Livehime            4.47. --accept-package-agreements --accept-source-agreements -h

   - 

   - 

找不到与输入条件匹配的程序包。
10:42:04 - ##########   WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID 'ili.Livehime            4.47.'   ##########
10:42:04 - 哔哩哔哩直播姬                                                 Bilib update failed.
10:42:07 - Updating Clash for Windows 0.20.28 from   0.20.28 to     0.20.29...
10:42:10 - ##########   WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '  Fndroid.ClashForWindows'   ##########
10:42:10 - -> Running: Winget upgrade --id   Fndroid.ClashForWindows --accept-package-agreements --accept-source-agreements -h

   - 
   \ 

   - 

找不到与输入条件匹配的已安装程序包。
10:42:14 - -> An upgrade for Clash for Windows 0.20.28 failed, now trying an install instead...
10:42:14 - -> Running: Winget install --id   Fndroid.ClashForWindows --accept-package-agreements --accept-source-agreements -h

   - 

   - 

找不到与输入条件匹配的程序包。
10:42:17 - ##########   WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID '  Fndroid.ClashForWindows'   ##########
10:42:17 - Clash for Windows 0.20.28 update failed.
10:42:21 - Updating Oh My Posh version 17.11.2 from   17.11.2 to     17.11.3...
10:42:24 - ##########   WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '  JanDeDobbeleer.OhMyPosh'   ##########
10:42:24 - -> Running: Winget upgrade --id   JanDeDobbeleer.OhMyPosh --accept-package-agreements --accept-source-agreements -h

   - 
   \ 

   - 

找不到与输入条件匹配的已安装程序包。
10:42:27 - -> An upgrade for Oh My Posh version 17.11.2 failed, now trying an install instead...
10:42:27 - -> Running: Winget install --id   JanDeDobbeleer.OhMyPosh --accept-package-agreements --accept-source-agreements -h

   - 

   - 

找不到与输入条件匹配的程序包。
10:42:31 - ##########   WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID '  JanDeDobbeleer.OhMyPosh'   ##########
10:42:31 - Oh My Posh version 17.11.2 update failed.
10:42:34 - Updating Epic Games Launcher from   1.3.67.0 to     1.3.78.0...
10:42:37 - ##########   WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '  EpicGames.EpicGamesLauncher'   ##########
10:42:37 - -> Running: Winget upgrade --id   EpicGames.EpicGamesLauncher --accept-package-agreements --accept-source-agreements -h

   - 

   - 

找不到与输入条件匹配的已安装程序包。
10:42:40 - -> An upgrade for Epic Games Launcher failed, now trying an install instead...
10:42:40 - -> Running: Winget install --id   EpicGames.EpicGamesLauncher --accept-package-agreements --accept-source-agreements -h

   - 

   - 

找不到与输入条件匹配的程序包。
10:42:44 - ##########   WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID '  EpicGames.EpicGamesLauncher'   ##########
10:42:44 - Epic Games Launcher update failed.
10:42:47 - No new update.
10:42:47 - End of process!

Additional information

$ winget upgrade --all
名称                                ID                           版本          可用          源
---------------------------------------------------------------------------------------------------
阿里云盘                            Alibaba.aDrive               4.5.0         4.6.1         winget
Microsoft Edge                      Microsoft.Edge               114.0.1823.82 114.0.1823.86 winget
Oh My Posh version 17.11.2          JanDeDobbeleer.OhMyPosh      17.11.2       17.11.3       winget
腾讯会议                            Tencent.TencentMeeting       3.18.3.433    3.18.4.441    winget
Clash for Windows 0.20.28           Fndroid.ClashForWindows      0.20.28       0.20.29       winget
哔哩哔哩直播姬                      Bilibili.Livehime            4.47.0.5019   4.48.0.5057   winget
Epic Games Launcher                 EpicGames.EpicGamesLauncher  1.3.67.0      1.3.78.0      winget
Microsoft Visual C++ 2015-2022 Red… Microsoft.VCRedist.2015+.x86 14.34.31938.0 14.36.32532.0 winget
guzy0324 commented 1 year ago

I think I have figured out why this happened. The Chinese characters are full width characters. They are 2 times wider than halfwidth characters.

This fixes the bug.

guzy0324 commented 1 year ago

Have a check at https://github.com/microsoft/winget-cli/issues/1753#issuecomment-1362193458. They provide structured outputs in the powershell module.

Romanitho commented 1 year ago

Yes, this is a well known problem with WAU. We are aware that we need to move to PowerShell module, but we are waiting for a stable version and we need to rework all the scripts.

Romanitho commented 1 year ago

Could you make a test for me please? :) Can you replace your function Get-WingetOutdatedApps.ps1 by this one: https://github.com/Romanitho/Winget-AutoUpdate/blob/Chinese-bug/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1

guzy0324 commented 1 year ago

Could you make a test for me please? :) Can you replace your function Get-WingetOutdatedApps.ps1 by this one: https://github.com/Romanitho/Winget-AutoUpdate/blob/Chinese-bug/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1

Line 31 to line 37 and line 47 to line 53 should be:

    #Get header titles [without remove seperator]
    $index = $lines[$fl] -split '(?<=\s)(?!\s)'

    # Line $fl has the header, we can find char where we find ID and Version [and manage non latin characters]
    $idStart = [System.Text.Encoding]::UTF8.GetByteCount($($index[0] -replace '[\u4e00-\u9fa5]', '**'))
    $versionStart = $idStart + [System.Text.Encoding]::UTF8.GetByteCount($($index[1] -replace '[\u4e00-\u9fa5]', '**'))
    $availableStart = $versionStart + [System.Text.Encoding]::UTF8.GetByteCount($($index[2] -replace '[\u4e00-\u9fa5]', '**'))

because the IndexOf won't work if non-latin characters are replaced with '**'.

Romanitho commented 1 year ago

Do you want to PR ? this way you get credited 😊

guzy0324 commented 1 year ago

Do you want to PR ? this way you get credited 😊

https://github.com/Romanitho/Winget-AutoUpdate/pull/367

guzy0324 commented 1 year ago

Could you make a test for me please? :) Can you replace your function Get-WingetOutdatedApps.ps1 by this one: https://github.com/Romanitho/Winget-AutoUpdate/blob/Chinese-bug/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1

I noticed that the Handle Chinese chars commit is not merged into the main branch. Also, for lines 61 to 62, the length of id and version should not subtract the $nameDeclination. Here’s the updated code:

            $software.Id = $line.Substring($idStart - $nameDeclination, $versionStart - $idStart).TrimEnd()
            $software.Version = $line.Substring($versionStart - $nameDeclination, $availableStart - $versionStart).TrimEnd()
Romanitho commented 1 year ago

Thanks for your help. Tested on my side, working great :)