majkinetor / au

Chocolatey Automatic Package Updater Module
GNU General Public License v2.0
227 stars 71 forks source link

Error on execution with Git plugin when executing update.ps1 #129

Closed echizenryoma closed 6 years ago

echizenryoma commented 6 years ago

I got this error message:

Running Git
  ERROR:
   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
   + FullyQualifiedErrorId : NullArray
Thilas commented 6 years ago

Could you provide more information about how you get this error? Any git repo? Gist? AV log?

echizenryoma commented 6 years ago
PS D:\Project\Chocolatey-Package> .\update_all.ps1
Updating 48 automatic packages at 2018-03-12 09:42:22
Push is disabled
.....
   [5/48] cemu is updated to 1.11.5 (16.39s)
.....

Running History
Saving history to D:\Project\Chocolatey-Package\Update-History.md

Running Gist
........

Running Git
  ERROR:
    Cannot index into a null array.

Finished 48 packages after .83 minutes.
1 updated, 0 pushed, 0 ignored
0 errors - 0 update, 0 push.

I am so sorry that language of my Windows is Simplified Chinese. This ERROR means that array is null.

Then I print $Global:Info

PS D:\Project\Chocolatey-Package> $Global:Info |where {($_.Updated -eq $True) -Or ($_.Pushed -eq $True)}

Path          : D:\Project\Chocolatey-Package\cemu
Name          : cemu
Updated       : True
Pushed        : False
RemoteVersion : 1.11.5
NuspecVersion : 1.11.4
Result        : {cemu - checking updates using AU version 2018.1.11, , nuspec version: 1.11.4, remote version: 1.11.5...}
Error         :
NuspecPath    : D:\Project\Chocolatey-Package\cemu\cemu.nuspec
NuspecXml     : #document
Ignored       : False
IgnoreMessage :
StreamsPath   : D:\Project\Chocolatey-Package\cemu\cemu.json
Streams       :

Windows: Windows 10 LSTB git version: git version 2.16.2.windows.1 Git method: SSH choco version: v0.10.8

Thilas commented 6 years ago

I guess you are talking about your own choco repo on GitHub? Do you have an update_vars.ps1 file next to your update_all.ps1? If you could provide at least an obfuscated one?

Thilas commented 6 years ago

I can't manage to reproduce this issue using your choco repo and running update_all.ps1. I'll need some help from you.

echizenryoma commented 6 years ago

my update_vars.ps1 is like:

# AU Packages Template: https://github.com/majkinetor/au-packages-template
# Copy this file to update_vars.ps1 and set the variables there. Do not include it in the repository.

$Env:au_Push = 'false'

$Env:gist_id = '06bd306e9a1c0a26e8d81fe185ef77d0'
$Env:github_user_repo = 'echizenryoma/Chocolatey-Package'
$Env:github_api_key = 'XXXXXXXXXXXXXXXXXXXX'

$Env:report_path = Join-Path $PSScriptRoot "Update-AUPackages.md"
$Env:history_path = Join-Path $PSScriptRoot "Update-History.md"
majkinetor commented 6 years ago

Maybe we should add some verbose messages in git plugin to help @echizenryoma troubleshoot this

Thilas commented 6 years ago

I like the idea but I'm not sure where to start with. I don't even see what array could be responsible for this error. The only one I thought about is $packages but it can't be this one according the stats mentionned at the end of the logs. Any idea on your side?

FYI, I can't reproduce the error using @echizenryoma's choco repo.

echizenryoma commented 6 years ago

If AU don't have any updates, it will not trigger this bug. You should downgrade a package, then run update_all.ps1. For example, edit cemu\cemu.nuspec

<version>1.11.5</version> --> <version>1.11.4</version>
Thilas commented 6 years ago

I already tried that but it works anyway.

echizenryoma commented 6 years ago

I don't know what the problem is. I has tried to new a virtual machine (Windows 2016 Server), but this bug exists anyway. So I am confused now. Please tell me how to print some verbose messages. Thank you for your attention.

echizenryoma commented 6 years ago

I edit C:\Program Files\WindowsPowerShell\Modules\AU\Plugins\Git.ps1 to:

Write-Host "`$Info: $Info"

[array]$packages = if ($Force) { $Info.result.updated } else { $Info.result.pushed }

Write-Host "`$packages: $packages"

if ($packages.Length -eq 0) { Write-Host "No package updated, skipping"; return }

then run update_all.ps1:

......
[4/49] cemu is updated to 1.11.5 (20.41s)
......

Running Git
$Info: @{result=; error_count=; error_info=; packages=System.Object[]; startTime=03/14/2018 08:42:35; minutes=.95; pushed=0; updated=1; ignored=0; stats=System.Object[]; options=System.Collections.Specialized.OrderedDictionary; plugin_results=System.Collections.Hashtable; plugin_errors=System.Collections.Hashtable}

$packages: AUPackage
  ERROR:
    Cannot index into a null array.

Then I am sure that result is null.

Thilas commented 6 years ago

What version of AU are you using? You can get it with this powershell command (Get-Command Update-AUPackages).Version.

echizenryoma commented 6 years ago

(Get-Command Update-AUPackages).Version

Major  Minor  Build  Revision
-----  -----  -----  --------
2018   1      11     -1
majkinetor commented 6 years ago

What happens when you add Force parameter in your update_all

https://github.com/majkinetor/au/blob/39551f83f51e4faeac5aa9f1e126fbf1a8da80b2/AU/Plugins/Git.ps1#L15-L16

echizenryoma commented 6 years ago

I was using Force in my update_all.ps1.

Git           = @{
        Password = $Env:github_api_key
        Force    = $true
    }
echizenryoma commented 6 years ago

I find if i use SSH method to git, which causes this problem. But I use HTTPs method to git, which is OK.

majkinetor commented 6 years ago

140