UniGetUI icon indicating copy to clipboard operation
UniGetUI copied to clipboard

[BUG] IndexOutOfRangeException with non global npm list

Open NorbertHD opened this issue 10 months ago • 5 comments

Please confirm these before moving forward

  • [X] I have searched for my issue and have not found a work-in-progress/duplicate/resolved issue.
  • [X] I have tested that this issue has not been fixed in the latest (beta or stable) release.
  • [X] I have checked the FAQ section for solutions
  • [X] This issue is about a bug (if it is not, please use the correct template)

Describe your issue

When WingetUi searches for npm updates there is an IndexOutOfRangeException in the logs.

"npm list" gives the output "`-- (empty)". After the split with "@" there is only one element in the "elements" array. And then "elements[1]" leads to the IndexOutOfRangeException.

Please add:

if (elements.Length >= 2)

before line 155 in file Npm.cs

Steps to reproduce the issue

No response

WingetUI Log

LoadComponentsAsync finished executing. All managers loaded. Proceeding to interface.
Error finding installed packages on manager Npm: 
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at ModernWindow.PackageEngine.Managers.Npm.GetInstalledPackages_UnSafe()
   at ModernWindow.PackageEngine.Classes.PackageManager.GetInstalledPackages() in Y:\WingetUI-Store\src\wingetui\PackageEngine\Classes\Manager.cs:line 192

Package Managers Logs

▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▀▀▀▀▀▀▀▀▀ [30.03.2024 16:44:50] Winget ▀▀▀▀▀▀▀▀▀▀▀
█  Executable: C:\Program Files\WingetUI\PackageEngine\Managers\winget-cli_x64\winget.exe
█  Arguments:  source list
Name    Argument
-----------------------------------------------------
msstore https://storeedgefd.dsx.mp.microsoft.com/v9.0
winget  https://cdn.winget.microsoft.com/cache
[30.03.2024 16:44:50] Exit Code: 0
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▀▀▀▀▀▀▀▀▀ [30.03.2024 16:44:50] Chocolatey ▀▀▀▀▀▀▀▀▀▀▀
█  Executable: C:\Users\Norbert\AppData\Local\Programs\WingetUI\choco-cli\choco.exe
█  Arguments:  source list
Chocolatey v2.2.2
chocolatey - https://community.chocolatey.org/api/v2/ | Priority 0|Bypass Proxy - False|Self-Service - False|Admin Only - False.
[30.03.2024 16:44:50] Exit Code: 0
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▀▀▀▀▀▀▀▀▀ [30.03.2024 16:44:51] PowerShell ▀▀▀▀▀▀▀▀▀▀▀
█  Executable: C:\Windows\system32\windowspowershell\v1.0\powershell.exe
█  Arguments:  -NoProfile -Command Get-PSRepository
Name                      InstallationPolicy   SourceLocation                                                          
----                      ------------------   --------------                                                          
PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2                                
[30.03.2024 16:44:51] Exit Code: 0
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▀▀▀▀▀▀▀▀▀ [30.03.2024 16:44:51] Winget ▀▀▀▀▀▀▀▀▀▀▀
█  Executable: C:\Program Files\WingetUI\PackageEngine\Managers\winget-cli_x64\winget.exe
█  Arguments:  source list
Name    Argument
-----------------------------------------------------
msstore https://storeedgefd.dsx.mp.microsoft.com/v9.0
winget  https://cdn.winget.microsoft.com/cache
[30.03.2024 16:44:51] Exit Code: 0
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▀▀▀▀▀▀▀▀▀ [30.03.2024 16:44:52] .NET Tool ▀▀▀▀▀▀▀▀▀▀▀
█  Executable: C:\Program Files\dotnet\dotnet.exe
█  Arguments: tool list --global
Paket-ID                   Version      Befehle              
-------------------------------------------------------------
dotnet-tools-outdated      0.7.1        dotnet-tools-outdated
[30.03.2024 16:44:52] Exit Code: 0
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▀▀▀▀▀▀▀▀▀ [30.03.2024 16:44:52] Chocolatey ▀▀▀▀▀▀▀▀▀▀▀
█  Executable: C:\Users\Norbert\AppData\Local\Programs\WingetUI\choco-cli\choco.exe
█  Arguments:  source list
Chocolatey v2.2.2
chocolatey - https://community.chocolatey.org/api/v2/ | Priority 0|Bypass Proxy - False|Self-Service - False|Admin Only - False.
[30.03.2024 16:44:52] Exit Code: 0
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▀▀▀▀▀▀▀▀▀ [30.03.2024 16:44:52] Pip ▀▀▀▀▀▀▀▀▀▀▀
█  Executable: C:\Users\Norbert\AppData\Local\Programs\Python\Python312\python.exe
█  Arguments:  -m pip list
Package            Version
------------------ --------
cffi               1.16.0
charset-normalizer 3.3.2
cryptography       42.0.5
Deprecated         1.2.14
deprecation        2.1.0
img2pdf            0.5.1
lxml               5.1.1
markdown-it-py     3.0.0
mdurl              0.1.2
ocrmypdf           16.1.2
packaging          24.0
pdfminer.six       20231228
pikepdf            8.14.0
pillow             10.2.0
pip                24.0
pluggy             1.4.0
pycparser          2.21
Pygments           2.17.2
rich               13.7.1
wrapt              1.16.0
[30.03.2024 16:44:52] Exit Code: 0
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▀▀▀▀▀▀▀▀▀ [30.03.2024 16:44:52] .NET Tool ▀▀▀▀▀▀▀▀▀▀▀
█  Executable: C:\Users\Norbert\.dotnet\tools\dotnet-tools-outdated.exe
█  Arguments: 
[30.03.2024 16:44:52] Exit Code: 0
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▀▀▀▀▀▀▀▀▀ [30.03.2024 16:44:52] Chocolatey ▀▀▀▀▀▀▀▀▀▀▀
█  Executable: C:\Users\Norbert\AppData\Local\Programs\WingetUI\choco-cli\choco.exe
█  Arguments:  list
Chocolatey v2.2.2
0 packages installed.
Did you know Pro / Business automatically syncs with Programs and
 Features? Learn more about Package Synchronizer at
 https://chocolatey.org/compare
[30.03.2024 16:44:52] Exit Code: 0
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▀▀▀▀▀▀▀▀▀ [30.03.2024 16:44:53] Chocolatey ▀▀▀▀▀▀▀▀▀▀▀
█  Executable: C:\Users\Norbert\AppData\Local\Programs\WingetUI\choco-cli\choco.exe
█  Arguments:  outdated
Chocolatey v2.2.2
Outdated Packages
 Output is package name | current version | available version | pinned?
Chocolatey has determined 0 package(s) are outdated. 
[30.03.2024 16:44:53] Exit Code: 0
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▀▀▀▀▀▀▀▀▀ [30.03.2024 16:44:53] PowerShell ▀▀▀▀▀▀▀▀▀▀▀
█  Executable: C:\Windows\system32\windowspowershell\v1.0\powershell.exe
█  Arguments:  -NoProfile -Command Get-PSRepository
Name                      InstallationPolicy   SourceLocation                                                          
----                      ------------------   --------------                                                          
PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2                                
[30.03.2024 16:44:53] Exit Code: 0
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▀▀▀▀▀▀▀▀▀ [30.03.2024 16:44:53] Winget ▀▀▀▀▀▀▀▀▀▀▀
█  Executable: C:\Program Files\WingetUI\PackageEngine\Managers\winget-cli_x64\winget.exe
█  Arguments:  list  --accept-source-agreements
   \ 
  ███▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  1024 KB / 9.71 MB
  ██████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  2.00 MB / 9.71 MB
  █████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  3.00 MB / 9.71 MB
  ████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  4.00 MB / 9.71 MB
  ███████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  5.00 MB / 9.71 MB
  ██████████████████▒▒▒▒▒▒▒▒▒▒▒▒  6.00 MB / 9.71 MB
  █████████████████████▒▒▒▒▒▒▒▒▒  7.00 MB / 9.71 MB
  ████████████████████████▒▒▒▒▒▒  8.00 MB / 9.71 MB
  ███████████████████████████▒▒▒  9.00 MB / 9.71 MB
  ██████████████████████████████  9.71 MB / 9.71 MB
   - 
Name                                     Id                                       Version          Available     Source
-----------------------------------------------------------------------------------------------------------------------
TortoiseGit                              0BF99681-825C-4B2A-A14F-2AC01DB9B70E_n6… 1.0.0.0                        
...
Microsoft Windows Desktop Runtime - 8.0… Microsoft.WindowsAppRuntime.1.5          < 1.5.0          1.5.1         winget
[30.03.2024 16:44:53] Exit Code: 0
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▀▀▀▀▀▀▀▀▀ [30.03.2024 16:44:54] Npm ▀▀▀▀▀▀▀▀▀▀▀
█  Executable: C:\Windows\system32\windowspowershell\v1.0\powershell.exe
█  Arguments:  -NoProfile -ExecutionPolicy Bypass -Command npm outdated --global --parseable
[30.03.2024 16:44:54] Exit Code: 0
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▀▀▀▀▀▀▀▀▀ [30.03.2024 16:44:54] Winget ▀▀▀▀▀▀▀▀▀▀▀
█  Executable: C:\Program Files\WingetUI\PackageEngine\Managers\winget-cli_x64\winget.exe
█  Arguments:  update --include-unknown  --accept-source-agreements
   \ 
   / 
  ███▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  1024 KB / 9.71 MB
  ██████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  2.00 MB / 9.71 MB
  █████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  3.00 MB / 9.71 MB
  ████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  4.00 MB / 9.71 MB
  ███████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  5.00 MB / 9.71 MB
  ██████████████████▒▒▒▒▒▒▒▒▒▒▒▒  6.00 MB / 9.71 MB
  █████████████████████▒▒▒▒▒▒▒▒▒  7.00 MB / 9.71 MB
  ████████████████████████▒▒▒▒▒▒  8.00 MB / 9.71 MB
  ███████████████████████████▒▒▒  9.00 MB / 9.71 MB
  ██████████████████████████████  9.71 MB / 9.71 MB
   - 
Name                                                 Id                              Version       Available     Source
-----------------------------------------------------------------------------------------------------------------------
Google Chrome                                        Google.Chrome                   123.0.6312.86 123.0.6312.87 winget
Mp3tag v3.24b                                        Mp3tag.Mp3tag                   3.24b         3.24          winget
Microsoft Visual C++ 2015-2022 Redistributable (x86… Microsoft.VCRedist.2015+.x86    14.38.33135.0 14.40.33617.1 winget
Microsoft Visual C++ 2015-2022 Redistributable (x64… Microsoft.VCRedist.2015+.x64    14.38.33135.0 14.40.33617.1 winget
Microsoft Windows Desktop Runtime - 8.0.3 (x64)      Microsoft.WindowsAppRuntime.1.5 < 1.5.0       1.5.1         winget
5 upgrades available.
[30.03.2024 16:44:54] Exit Code: 0
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▀▀▀▀▀▀▀▀▀ [30.03.2024 16:44:54] PowerShell ▀▀▀▀▀▀▀▀▀▀▀
█  Executable: C:\Windows\system32\windowspowershell\v1.0\powershell.exe
█  Arguments:  -NoProfile -Command Get-InstalledModule
Version              Name                                Repository           Description                              
-------              ----                                ----------           -----------                              
1.4.8.1              PackageManagement                   PSGallery            PackageManagement (a.k.a. OneGet) is a...
5.5.0                Pester                              PSGallery            Pester provides a framework for runnin...
2.2.5                PowerShellGet                       PSGallery            PowerShell module with commands for di...
2.3.4                PSReadLine                          PSGallery            Great command line editing in the Powe...
[30.03.2024 16:44:54] Exit Code: 0
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▀▀▀▀▀▀▀▀▀ [30.03.2024 16:44:54] Pip ▀▀▀▀▀▀▀▀▀▀▀
█  Executable: C:\Users\Norbert\AppData\Local\Programs\Python\Python312\python.exe
█  Arguments:  -m pip list --outdated
Package   Version Latest Type
--------- ------- ------ -----
pycparser 2.21    2.22   wheel
[30.03.2024 16:44:54] Exit Code: 0
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▀▀▀▀▀▀▀▀▀ [30.03.2024 16:44:56] PowerShell ▀▀▀▀▀▀▀▀▀▀▀
█  Executable: C:\Windows\system32\windowspowershell\v1.0\powershell.exe
█  Arguments: 
Windows PowerShell
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.
Installieren Sie die neueste PowerShell f�r neue Funktionen und Verbesserungen! https://aka.ms/PSWindows
PS C:\Program Files\WingetUI> 
PS C:\Program Files\WingetUI>                 function Test-GalleryModuleUpdate {
>>                     param (
>>                         [Parameter(Mandatory,ValueFromPipelineByPropertyName)] [string] $Name,
>>                         [Parameter(Mandatory,ValueFromPipelineByPropertyName)] [version] $Version,
>>                         [Parameter(Mandatory,ValueFromPipelineByPropertyName)] [string] $Repository,
>>                         [switch] $NeedUpdateOnly
>>                     )
>>                     process {
>>                         $URLs = @{}
>>                         @(Get-PSRepository).ForEach({$URLs[$_.Name] = $_.SourceLocation})
>>                         $page = Invoke-WebRequest -Uri ($URLs[$Repository] + "/package/$Name") -UseBasicParsing -Maximum 0 -ea Ignore
>>                         [version]$latest = Split-Path -Path ($page.Headers.Location -replace "$Name." -replace ".nupkg") -Leaf
>>                         $needsupdate = $Latest -gt $Version
>>                         if ($needsupdate) {
>>                                 Write-Output($Name + "|" + $Version.ToString() + "|" + $Latest.ToString() + "|" + $Repository)
>>                         }
>>                     }
>>                 }
>>                 Get-InstalledModule | Test-GalleryModuleUpdate
PS C:\Program Files\WingetUI>                 exit
[30.03.2024 16:44:56] Exit Code: 0

Relevant information

No response

Screenshots and videos

No response

NorbertHD avatar Mar 30 '24 14:03 NorbertHD

Please shatr your Package Manager logs, so I can see which packages are failing

marticliment avatar Mar 30 '24 15:03 marticliment

Original post updated with Package Manager log. Thanks for looking into it.

NorbertHD avatar Mar 30 '24 15:03 NorbertHD

Nice!

marticliment avatar Mar 30 '24 16:03 marticliment

I'm also getting this error on version 3.0.2:

LoadComponentsAsync finished executing. All managers loaded. Proceeding to interface. Error finding installed packages on manager Npm: System.IndexOutOfRangeException: Index was outside the bounds of the array. at ModernWindow.PackageEngine.Managers.Npm.GetInstalledPackages_UnSafe() at ModernWindow.PackageEngine.Classes.PackageManager.GetInstalledPackages() in C:\Users\marti\Desktop\wingetui-tempo\src\wingetui\PackageEngine\Classes\Manager.cs:line 192 Invalid value for UpdatesCheckInterval, using default value of 3600 seconds

Is there any extra info I can provide?

edumserrano avatar Apr 19 '24 20:04 edumserrano

This is fine, I don't need more details

marticliment avatar Apr 19 '24 22:04 marticliment