Expanding zip archive seems to cause an error when I run flutter doctor on powershell

Viewed 639

I get this error when I run flutter doctor

PS C:\Users\CHIDUBEM> flutter doctor
Checking Dart SDK version...
Downloading Dart SDK from Flutter engine 6bc433c6b6b5b98dcf4cc11aff31cdee90849f32...
Unzipping Dart SDK...
New-Object : Exception calling ".ctor" with "3" argument(s): "Central Directory corrupt."
At C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:934 char:23
+ ... ipArchive = New-Object -TypeName System.IO.Compression.ZipArchive -Ar ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

Building flutter tool...
Running pub upgrade...
The system cannot find the path specified.
Error (1): Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (9 tries left)

The second error is supposed to be rectified by deleting the cache folder in flutter/bin and running flutter doctor but this happens every time

1 Answers

You can edit your located psm1 file with the following one:


        $zipArchiveArgs = @($archiveFileStream, [System.IO.Compression.ZipArchiveMode]::Read, $false)
        try
        {
            $zipArchive = New-Object -TypeName System.IO.Compression.ZipArchive -ArgumentList $zipArchiveArgs
        }
        catch [System.IO.InvalidDataException]
        {
            # Failed to open the file for reading as a zip archive. Wrap the exception
            # and re-throw it indicating it does not appear to be a valid zip file.
            $exception = $_.Exception
            if($null -ne $_.Exception -and
               $null -ne $_.Exception.InnerException)
            {
                $exception = $_.Exception.InnerException
            }
            # Load the WindowsBase.dll assembly to get access to the System.IO.FileFormatException class
            [System.Reflection.Assembly]::Load('WindowsBase,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35')
            $invalidFileFormatException = New-Object -TypeName System.IO.FileFormatException -ArgumentList @(
                ($LocalizedData.ItemDoesNotAppearToBeAValidZipArchive -f $archiveFile)
                $exception
            )
            throw $invalidFileFormatException
        }
Related